+ 4
How to repeat a String in java
in python "#"*5 is equal to "#####" but how to do that in java is there an easy method ?
6 Respostas
+ 4
You could use a for loop, or just copy/paste
+ 3
with java8 you can use this oneliner:
String.join("", Collections.nCopies(5, "#"));
+ 2
Check out my stringrepeatfunction program.
+ 2
you could use a loop
class repeat {
public static void main (String[] args) {
string test = "#"
for(int i=0, i<5, i++)
{
System.out.print(test);
}
}
}
+ 1
oh
I thought there would be an easy method
anyway thanks
+ 1
thanks
I just thought there would be some kind of built in function