+ 2
How can I print my name 1000 times in Java without using loops?
4 Respostas
+ 2
Hello,Applet
Please follow the bellow login
package com.mkyong.samples;
public class hello{
public static void main(String[] args) {
String s1 = "Mkyong\n";
String s3 = s1 + s1 + s1;
String s10 = s3 + s3 + s3 + s1;
String s30 = s10 + s10 + s10;
String s100 = s30 + s30 + s30 + s10;
String s300 = s100 + s100 + s100;
String s1000 = s300 + s300 + s300 + s100;
System.out.print(s1000);
}
}
i hope this will help to you
+ 4
The linked article is a bit hard to follow, so, keeping it simple:
Recursion.
Ishan Shah Wow🤐
+ 3
There are the solutions here, I could not provide directly my answer:
https://www.quora.com/How-do-I-print-my-name-1000-times-in-Java-without-looping
+ 2
You can use IntStream.
//import java.util.stream.IntStream;
IntStream.range(0,100).
mapToObj(i -> "my name").
forEach(System.out::println);