Results 1 to 4 of 4
  1. #1
    kraig9 is offline Kraig9
    Join Date
    Jun 2012
    Location
    Central Texas
    Posts
    3
    Rep Power
    0

    Post Problem with "for" loop

    New to Java and programming in general... What is wrong with my loop? (In Eclipse)





    package variation;

    public class VariationFromCandy {
    public static void main(String[] args){
    for (int x=0; x>-40; x = x - 5);
    System.out.println(x + "da number is"); //it gives me an error on x in (x + "da number is") edit: It states that "x cannot be resolved to a variable."
    }
    }
    Last edited by kraig9; 06-11-2012 at 08:17 PM.

  2. #2
    KevinWorkman's Avatar
    KevinWorkman is offline Crazy Cat Lady
    Join Date
    Oct 2010
    Location
    Washington, DC
    Posts
    4,038
    Rep Power
    10

    Default Re: Problem with "for" loop

    Check your semicolons.
    How to Ask Questions the Smart Way
    Static Void Games - Play indie games, learn from game tutorials and source code, upload your own games!

  3. #3
    sehudson's Avatar
    sehudson is offline Senior Member
    Join Date
    Mar 2010
    Posts
    364
    Rep Power
    5

    Default Re: Problem with "for" loop

    You put a semicolon after your for loop condition. It should be an opening parenthesis:


    Java Code:
    for(int x=0; x>-40; x=x-5){
     System.out.println(x + "da number is");
    }

  4. #4
    kraig9 is offline Kraig9
    Join Date
    Jun 2012
    Location
    Central Texas
    Posts
    3
    Rep Power
    0

    Default Re: Problem with "for" loop

    Oh! Thanks guys it ran perfectly after that.

Similar Threads

  1. Replies: 18
    Last Post: 04-03-2012, 10:49 AM
  2. Replies: 1
    Last Post: 02-01-2012, 09:37 PM
  3. An "if" statement inside a "for" loop?
    By soccermiles in forum New To Java
    Replies: 18
    Last Post: 04-20-2010, 04:44 AM
  4. problem with argument list and precedence "(" and ")"
    By helpisontheway in forum Advanced Java
    Replies: 6
    Last Post: 12-24-2009, 08:50 AM
  5. Replies: 1
    Last Post: 10-20-2008, 08:35 AM

Tags for this Thread

Posting Permissions

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