KnowledgeBoat Logo

Computer Applications

Find the error

for(count = 0,  count < 5,  count = count + 1)	
System.out.println("This is  count:" + count);	
    System.out.println("Done!");	

Java Nested for Loops

1 Like

Answer

The errors are as follows:

  1. The variable count is not declared. It needs to be declared before it can be used.
  2. The syntax of 'for' loop requires semicolons ( ; ) as separators, and not comma ( , ). The correct code is as follows:
for(int count = 0;  count < 5;  count = count + 1)    
    System.out.println("This is  count:" + count);  
System.out.println("Done!");

Answered By

1 Like


Related Questions