Java | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 1

Java

Hi, how can i write this in java. Thanks * *** ***** *** *

16th Jan 2021, 8:49 PM
Ehsan
Ehsan - avatar
5 Answers
+ 3
You need for loops to create these patterns have a try if you fail think differently about it if you still cant do it, show me your efforts and I'll help you.
16th Jan 2021, 9:04 PM
D_Stark
D_Stark - avatar
+ 3
In your program, the i needs to increment by 2 each time. You will also need another nested set of loops where the outer loop counter is defermented by 2 in each iteration.
17th Jan 2021, 12:39 AM
Sonic
Sonic - avatar
+ 1
public class Program { public static void main(String[] args) { for(int i=1; i<=5; i++){ for(int j=1; j<=i ;j++){ System.out.print("*"); } System.out.println(" "); } } }
16th Jan 2021, 9:15 PM
Ehsan
Ehsan - avatar
+ 1
i could only write that
16th Jan 2021, 9:17 PM
Ehsan
Ehsan - avatar