Home » Java » java – Variable name for nested for loop question-Exceptionshub

java – Variable name for nested for loop question-Exceptionshub

Posted by: admin February 25, 2020 Leave a comment

Questions:

this is a very weird and basic question. generally when your doing a nested for Loop should you use the i variable as the main variable and j as the nested variable. When im doing it (i am a new programmer) in Java, i always use j as the variable for the outer loop. and i as the internal loop.
is this bad practice or does it not make any difference. I do know technically it does not matter what I name the variable. But i don’t want to go to developer hell as I’ve nearly been sent to for bad indenting in previous projects.

for(j=0;j<100;j++){
    for(i=0;i<100;i++){
    // Insert code here
    // example
    }
}


How to&Answers: