Current location - Plastic Surgery and Aesthetics Network - Plastic surgery and beauty - Can java use the for loop to define integer assignment?
Can java use the for loop to define integer assignment?
According to my understanding of your question, I don't think so unless you declare multiple variables and add judgment.

for(int I = 1; I<7; i++){

int a 1,a2,a3,a4,a5,a6;

Switch (i) (

Case 1:

a 1 = I * I;

Break;

Case 2:

a2 = i * i

Break;

...

}

}

If you want to store something, you must first give an exact type. name, int is the declaration type, and A is the name of the variable. The value of the variable can be changed, but the declaration of the variable cannot be changed.

For example, when you were born, you had an ID number. This ID number refers to you. No matter how old you are, your ID number will not change. You can't say that 1 is added to your ID number just because you are one year older.

When you declare a 1, you open a space for it in the stack. The next time you declare a2, a new space will be opened instead of changing the original a 1 to a2.