Results 1 to 4 of 4
  1. #1
    jo15765 is offline Member
    Join Date
    May 2012
    Posts
    42
    Rep Power
    0

    Default Java Compile Error

    I am running the code below
    Java Code:
    int number;
    
    largestNum = 0;
    int[] arrayInput = new int[11];
    
    for (counter = 1; counter < arrayInput.length; counter++);
    {
    userInput = 0;
    
    //this is where I thought I was using the variable?
    number = 0;
    
    //More code below
    The compile error I receive is the value of the local variable number is not used. Do I not assign the value to 0, which would be using the number?

  2. #2
    JosAH's Avatar
    JosAH is offline Moderator
    Join Date
    Sep 2008
    Location
    Voorschoten, the Netherlands
    Posts
    13,785
    Blog Entries
    7
    Rep Power
    21

    Default Re: Java Compile Error

    You wrote a value (assigned) to the variable but you never read the variable value anywhere so you never actually used the variable value. b.t.w. it's a compiler warning, not an error.

    kind regards,

    Jos
    cenosillicaphobia: the fear for an empty beer glass

  3. #3
    jo15765 is offline Member
    Join Date
    May 2012
    Posts
    42
    Rep Power
    0

    Default Re: Java Compile Error

    Ah, that makes more sense. I am switching over to eclipse from notepad++ so I am not used to seeing the compiler errors. Thanks for the valuable insight.

  4. #4
    kalata is offline Member
    Join Date
    Aug 2011
    Location
    Bulgaria
    Posts
    29
    Rep Power
    0

    Default Re: Java Compile Error

    Hi, remove the semicolon after the "for" statement and see if it works.

    BR,
    Kalin

Similar Threads

  1. Java compile error
    By missmara77 in forum New To Java
    Replies: 1
    Last Post: 10-31-2011, 09:49 PM
  2. Java Compile error?
    By AlleDingeAndern in forum New To Java
    Replies: 6
    Last Post: 02-07-2011, 10:50 AM
  3. Java compile error
    By socboy6579 in forum New To Java
    Replies: 7
    Last Post: 10-14-2010, 07:48 PM
  4. Java Compile error
    By pablo2002 in forum Java Applets
    Replies: 8
    Last Post: 09-12-2010, 03:48 AM
  5. Java 1.5 compile time error
    By ank_k in forum New To Java
    Replies: 4
    Last Post: 11-13-2008, 12:12 PM

Posting Permissions

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