There won't be a loop for the loop

I have a for loop that I will use to calculate the time intervals to add to the ArrayList. The problem is that I cannot prove that the for loop is executing. Nothing is printed when using the system.out.println () instruction, and nothing is added to the array from the loop ... any sugestions?

// lager tidspunkter og legger disse inn i en Array kalt tider tid.setTimer(16); tid.setMinutter(0); tid.setSekunder(0); tider.add(tid.asString());// String "16:00" is added as it should System.out.println("tiden er: "+tid.asString());// gives 16:00 printed for(int i=0;i>12;i++){ System.out.println("er i løkken");// gives nothing printed tid.increaseMinutter(30); System.out.println(tid.asString());// gives nothing printed tider.add(tid.asString()); } 
+4
source share
6 answers

You mean less, no more:

 for(int i=0;i<12;i++){ // ^ 
+20
source

You are mistaken: Change i>12 to i<12 .

+9
source

You have a typo in your for loop: it should be me <12

+5
source

I believe that you plan to process elements from 0 to 11. Therefore, the for loop should be

 for(int i=0;i<12;i++) 

Instead, you entered

 for(int i=0;i>12;i++) 
+3
source

By mistake, you wrote here for(int i=0;i>12;i++) . For a loop, the value i initialized to 0 first, and then the condition i>12 is checked, which is false, so your program does not enter the block of the for loop and prints nothing. If you want the for loop block to be executed, enter for(int i=0;i<12;i++) and everything will be correct.

0
source

your code> for (int i = 0; i> 12; i ++) // more than

Changes>

 (1) for(int i=0;i<12;i++) // less than OR (2) for(int i=11;i>=0;i--) // starting from size-1 
0
source

Source: https://habr.com/ru/post/1411514/


All Articles