-1
I need to create two bonds going from 1 to 10, only one inside another.
WORKS
- Using for and for.
 - Using while e for.
 
Why doesn’t it work?
1) WHILE AND WHILE
int a=1, b=1;
    while(a<=10) {          
        while(b<=10) {
            System.out.print(a + "-" + b + "  ");
            b++;
        } //fim while b
        System.out.println("");
        a++;
    }//fim while a
2) FOR E WHILE
int b=1;
    for(int a=1; a<=10; a++) {
        while(b<=10) {
            System.out.print(a + "-" + b + "  ");
            b++;                
        }// fim while b
    }// fim for a
						
Adding to your answer: In FOR loops, every time you iterate again through the loop, the variable starts again. What happens is that there is a new variable declaration in each loop iteration, and so its value is always updated (i++ uses i in the current value and adds +1 to the next statement) so in its declaration it is usually seen to be (int i = 0; i < x; i++).
– Marcos de Andrade