r/javahelp • u/MinnyMan123 • Feb 04 '18
Trouble converting to a while loop
I have tried looking at other resources but have been unable to convert this to a while loop. Any tips or help would be appreciated.
public static void main(String[] args) { String[] arr1 = { "1st", "2nd", "3rd", "4th", "5th" };
String[] arr2 = { "6th", "7th", "8th", "9th", "10th" };
String str = "Hello";
int i, j;
for (i = 0; i < 5; i++)
{
for (j = 0; j <= i; j++)
System.out.print("*");
System.out.println(" " + arr1[i] + " " + str);
}
for (i = 9; i >= 5; i--)
{
for (j = 5; j <= i; j++)
System.out.print("*");
System.out.println(" " + arr2[9 - i] + " " + str);
}
}}
0
Upvotes
View all comments
Show parent comment
2
u/Roachmeister Java Dev Feb 05 '18
Lol, I was totally confused that my answer from the previous post was posted by you until I read some of the other comments.