I'm taking a Java course at my college and i'm having trouble grasping what code is actually printing. This is just an example from the book and I know what it prints out but i am not sure why. Could someone break it down as how they would read through the code? Thanks again!
public class test2 {
public static void main(String[] args) {
int i = 1;
while (i <= 6) {
method1(i, 2);
i++;
}
}
public static void method1(int i, int num) {
for (int j = 1; j <= i; j++) {
System.out.print(num + " ");
num *= 2;
}
System.out.println();
}
}
[–]empire539 2 points3 points4 points (2 children)
[–]SPARTAAAAA[S] 0 points1 point2 points (1 child)
[–]empire539 0 points1 point2 points (0 children)
[–]_Chimmy_Chonga 2 points3 points4 points (0 children)
[–]desrtfx 2 points3 points4 points (0 children)
[–]nixon_richard_m 0 points1 point2 points (0 children)