Welcome to the Java Programming Forums


The professional, friendly Java community. 21,500 members and growing!


The Java Programming Forums are a community of Java programmers from all around the World. Our members have a wide range of skills and they all have one thing in common: A passion to learn and code Java. We invite beginner Java programmers right through to Java professionals to post here and share your knowledge. Become a part of the community, help others, expand your knowledge of Java and enjoy talking with like minded people. Registration is quick and best of all free. We look forward to meeting you.


>> REGISTER NOW TO START POSTING


Members have full access to the forums. Advertisements are removed for registered users.

Results 1 to 2 of 2

Thread: Problem with code, pls help!

  1. #1
    Junior Member
    Join Date
    May 2014
    Posts
    29
    Thanks
    13
    Thanked 0 Times in 0 Posts

    Default Problem with code, pls help!

    public class Apples{
        public static void main (String args[]){
        	for(int counter=1;counter<=10;counter++);{
        		System.out.println(counter);
        	}
        }
       }
    Eclipse error message: Exception in thread "main" java.lang.Error: Unresolved compilation problem:
    counter cannot be resolved to a variable

    at Apples.main(Apples.java:5)


  2. #2
    Super Moderator Norm's Avatar
    Join Date
    May 2010
    Location
    SW Missouri
    Posts
    20,328
    Thanks
    49
    Thanked 2,194 Times in 2,167 Posts

    Default Re: Problem with code, pls help!

    The extra ; ends the if statement. The code in the {}s is not part of the if where counter is defined.
    If you don't understand my answer, don't ignore it, ask a question.

  3. The Following User Says Thank You to Norm For This Useful Post:

    nikolaiL (May 11th, 2014)

Similar Threads

  1. [SOLVED] What is wrong with my code? pls help!
    By nikolaiL in forum What's Wrong With My Code?
    Replies: 21
    Last Post: May 10th, 2014, 04:52 PM
  2. Pls check my code
    By javamonkey30 in forum Loops & Control Statements
    Replies: 12
    Last Post: March 18th, 2013, 02:26 PM
  3. Code snippet pls?
    By srinivas0615 in forum What's Wrong With My Code?
    Replies: 1
    Last Post: July 30th, 2011, 02:28 AM
  4. Could some pls help me out with this code??
    By Pearl in forum What's Wrong With My Code?
    Replies: 2
    Last Post: March 19th, 2011, 11:01 AM
  5. pls tell me where the problem is....
    By subhopam in forum What's Wrong With My Code?
    Replies: 1
    Last Post: November 16th, 2009, 01:53 PM