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 6 of 6

Thread: .'class' expected - what to do?!?! URGENT

  1. #1
    Junior Member
    Join Date
    Aug 2011
    Posts
    18
    Thanks
    5
    Thanked 0 Times in 0 Posts

    Exclamation .'class' expected - what to do?!?! URGENT

    hi guys, this is my code:

    public class appl
    {
    public static void main( String args[])
    {
    For(int i=0;i<=25;i++)
    int = 25;
    {
    System.out.print1n("the cost of the apples is #304.25");
    }
    }



    when i compile it, it keeps saying .'class' expected?? what do i do?!

    R x thanks in advance


  2. #2
    Banned
    Join Date
    May 2010
    Location
    North Central Illinois
    Posts
    1,631
    My Mood
    Sleepy
    Thanks
    390
    Thanked 112 Times in 110 Posts

    Default Re: .'class' expected - what to do?!?! URGENT

    The for statement isn't capitalized for one.

    For another, you need a {
    after the for statement

    third, you have a bracket after that statement
    int =25;

    Oh, also, you can't do

    int = 25;

    int is a variable type.

    int someName = 25 is valid.

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

    Rads23 (August 17th, 2011)

  4. #3
    Junior Member
    Join Date
    Aug 2011
    Posts
    18
    Thanks
    5
    Thanked 0 Times in 0 Posts

    Default Re: .'class' expected - what to do?!?! URGENT

    public class aappless
    {
    public static void main( String args[] )
    {
    For(int=y=0;y<=25;y++)
    {
    System.out.print1n("the cost of the apples is #304.25");
    }
    }



    sorry thats the coding, not the one in top!!

    sorry i didnt seem to understand what u meant?

  5. #4
    Banned
    Join Date
    May 2010
    Location
    North Central Illinois
    Posts
    1,631
    My Mood
    Sleepy
    Thanks
    390
    Thanked 112 Times in 110 Posts

    Default Re: .'class' expected - what to do?!?! URGENT

    int = y =0 is invalid. int y =0 works

    Also, once again, the for is not capitalized.

    Also, you're missing an ending bracket at the end for your class.

  6. The Following User Says Thank You to javapenguin For This Useful Post:

    Rads23 (August 17th, 2011)

  7. #5
    Junior Member
    Join Date
    Aug 2011
    Posts
    18
    Thanks
    5
    Thanked 0 Times in 0 Posts

    Default Re: .'class' expected - what to do?!?! URGENT

    Done it got it! thank you!

  8. #6
    Grand Poobah
    Join Date
    Mar 2011
    Posts
    1,545
    My Mood
    Grumpy
    Thanks
    0
    Thanked 167 Times in 158 Posts

    Default Re: .'class' expected - what to do?!?! URGENT

    Quote Originally Posted by javapenguin View Post
    you need a { after the for statement
    No you don't.
    you have a bracket after that statement int =25;
    Placing a bracket there is perfectly fine as long as there was a matching closing bracket.

    The code might not do what is expected but would compile and run.
    Improving the world one idiot at a time!

Similar Threads

  1. Need urgent help regarding java word wrap function.. URGENT
    By coldice in forum What's Wrong With My Code?
    Replies: 3
    Last Post: August 16th, 2011, 05:43 AM
  2. [SOLVED] Output isn't as expected.
    By woodcutterni in forum What's Wrong With My Code?
    Replies: 2
    Last Post: February 12th, 2011, 11:55 AM
  3. Identifier expected
    By Sphinx in forum What's Wrong With My Code?
    Replies: 5
    Last Post: November 30th, 2010, 02:50 PM
  4. <identifier> expected
    By Trunk Monkeey in forum What's Wrong With My Code?
    Replies: 1
    Last Post: November 21st, 2010, 09:33 PM
  5. ';' expected?
    By noobish in forum What's Wrong With My Code?
    Replies: 4
    Last Post: November 21st, 2009, 11:55 AM