+ 2

How can I print my name 1000 times in Java without using loops?

19th Jun 2020, 1:48 AM
Applet
Applet - avatar
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
19th Jun 2020, 6:47 AM
Ishan Shah
Ishan Shah - avatar
+ 4
The linked article is a bit hard to follow, so, keeping it simple: Recursion. Ishan Shah Wow🤐
19th Jun 2020, 2:52 AM
Kevin ★
+ 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
19th Jun 2020, 1:57 AM
James Clark I. Vinarao
James Clark I. Vinarao - avatar
+ 2
You can use IntStream. //import java.util.stream.IntStream; IntStream.range(0,100). mapToObj(i -> "my name"). forEach(System.out::println);
19th Jun 2020, 1:03 PM
0_O-[Mägár_Sám_Äkà_Nüllpøïntêr_Èxëcéptïön]~~
0_O-[Mägár_Sám_Äkà_Nüllpøïntêr_Èxëcéptïön]~~ - avatar