Results 1 to 3 of 3
  1. #1
    allan is offline Member
    Join Date
    Jan 2014
    Posts
    7
    Rep Power
    0

    Default program keeps looping

    im trying to test values stored in 2d arrays once but i my program just keeps looping what am i doing wrong


    Java Code:
    		
                           tempi=i;
    			tempx=x;
    		for( i=0;i<3;i++)
    			{
    				for( x=0;x<4;x++)
    				{
    					if(rounded[i][x]<395 || rounded[i][x] >405)
    					{
    						System.out.println("there is an error with probes "+rounded[i][x]);
    					}
    					
    					else if(values[i=0][x]< 400)
    					{
    						System.out.println("all points in element "+tempi+"as they are below 400 needs replaced("+"point "+tempx+" : "+values[i][x]+")");
    						
    						
    						
    					}
    				else if(values[i=1][x]<400)
    				{
    					System.out.println("all points in element "+tempi+"as they are below 400 needs replaced("+"point "+tempx+" : "+values[i][x]+")");
    					
    					
    					
    				}
    				else if(values[i=2][x]<400)
    				{
    					System.out.println("all points in element "+tempi+"as they are below 400 needs replaced("+"point "+tempx+" : "+values[i][x]+")");
    					
    				}
    				}
    					
    			
    			}
    				
    				
    				
    					
    			
    			}
    Last edited by allan; 01-13-2014 at 12:01 AM.

  2. #2
    AlexGraal is offline Señor Member
    Join Date
    Jan 2014
    Posts
    175
    Rep Power
    0

    Default Re: program keeps looping

    I just tried it and it worked just fine (looping-wise, it didn't keep looping).

    Though, your example isn't compilable or useable so I had to add stuff. You need to post a short, compilable and executable code that demonstrates the issue.

    Furthermore, it would be much easier for you (or anybody else) to work with and understand if you styled it correctly and got rid of all of the huge empty spaces.

    REDACTED A WRONG IDEA HERE
    Last edited by AlexGraal; 01-13-2014 at 12:24 AM.

  3. #3
    superhaNds is offline Senior Member
    Join Date
    Apr 2013
    Location
    Sweden
    Posts
    264
    Rep Power
    2

    Default Re: program keeps looping

    Quote Originally Posted by AlexGraal View Post
    Any time you only have one line after an if statement, { } isn't needed
    Java Code:
    if(somethingIsTrue) {
      System.out.println("It worked!");
    }
    Java Code:
    if(somethingIsTrue) 
      System.out.println("It worked!");
    Both are valid, but the second one is much cleaner (at least in my opinion).

    That's a big no no. Code without brackets is a mess and highly error prone. And against the code conventions

Similar Threads

  1. need some help in looping
    By toume in forum New To Java
    Replies: 5
    Last Post: 12-24-2012, 03:15 PM
  2. help with program!! looping issue?
    By zombian in forum New To Java
    Replies: 6
    Last Post: 11-21-2010, 10:14 PM
  3. Looping
    By Dean29126 in forum New To Java
    Replies: 3
    Last Post: 09-08-2010, 02:01 PM
  4. Help with While and For Looping
    By gmoney8316 in forum New To Java
    Replies: 2
    Last Post: 03-03-2010, 10:54 PM
  5. Looping Help Please
    By JonnySnip3r in forum New To Java
    Replies: 5
    Last Post: 01-31-2010, 05:57 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •