免费的企业建站cms,西安做网站找缑阳建,网站开发PRD,网络维护是什么职业String的函数public String repeat(int count)#xff0c;可以将当前字符串重复count次串接起来输出。 如果字符串是空的#xff0c;或者count的值是0#xff0c;那么返回空字符串。
代码示例1#xff1a;
package com.thb;public class Test5 {public static void main(…String的函数public String repeat(int count)可以将当前字符串重复count次串接起来输出。 如果字符串是空的或者count的值是0那么返回空字符串。
代码示例1
package com.thb;public class Test5 {public static void main(String[] args) {String str hello.repeat(2);System.out.println(str);}}运行输出
代码示例2输出多个*号
package com.thb;public class Test5 {public static void main(String[] args) {String str *.repeat(20);System.out.println(str);}}运行输出