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: what is wrong with this code?

  1. #1
    Junior Member
    Join Date
    Nov 2013
    Posts
    3
    Thanks
    2
    Thanked 0 Times in 0 Posts

    Question what is wrong with this code?

     public static void main(String[] args) {
            // TODO code application logic here
            Scanner in = new Scanner(System.in);
    	double a;
    	double b;
    	System.out.println("Dette program vil gøre så du kan sammenligne to tal og få forskellen af vide");
    	System.out.println("Vær sød at  skrive det første tal du vil sammenligne");
    	a=in.nextDouble();
    	System.out.println("Vær sød at skrive det andet tal du vil sammenligne");
    	b=in.nextDouble();
    	if (a == b);
    	System.out.println("De to tal er lige store");
            if else; <--- PROBLEM HERE
    	System.out.println("Det to tal er ikke lige store");

    se if else;. why is that wrong, it says: `(´ is expected

    illegal start of expression


  2. #2
    Super Moderator
    Join Date
    Jun 2013
    Location
    So. Maryland, USA
    Posts
    5,517
    My Mood
    Mellow
    Thanks
    215
    Thanked 698 Times in 680 Posts

    Default Re: what is wrong with this code?

    Executable statements must be inside a method. Where is your main() method?

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

    Linus (November 17th, 2013)

  4. #3
    Junior Member
    Join Date
    Nov 2013
    Posts
    3
    Thanks
    2
    Thanked 0 Times in 0 Posts

    Default Re: what is wrong with this code?

    i thought i didnt need to display it because it was irelevant but i was wrong. editing. there

  5. #4
    Super Moderator
    Join Date
    Jun 2013
    Location
    So. Maryland, USA
    Posts
    5,517
    My Mood
    Mellow
    Thanks
    215
    Thanked 698 Times in 680 Posts

    Default Re: what is wrong with this code?

    Review the if() and else/if statement construction. Ending an if() statement with a semi-colon ends the if statement before the code following. And there's no such statement is "if else;"

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

    Linus (November 17th, 2013)

  7. #5
    Junior Member
    Join Date
    Nov 2013
    Posts
    3
    Thanks
    2
    Thanked 0 Times in 0 Posts

    Default Re: what is wrong with this code?

    wow thanks you helped me alot. now i just need to learn how to export it as a downloadable and runable file, like an .exe

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

    Default Re: what is wrong with this code?

    Use a jar file not an exe file.
    Improving the world one idiot at a time!

Similar Threads

  1. What's wrong with my code?
    By SecTech in forum What's Wrong With My Code?
    Replies: 3
    Last Post: September 23rd, 2013, 07:38 PM
  2. What is wrong with my code
    By chaffee in forum What's Wrong With My Code?
    Replies: 1
    Last Post: June 18th, 2013, 06:39 AM
  3. What is wrong with my code?
    By docthoi in forum Java Theory & Questions
    Replies: 13
    Last Post: February 3rd, 2013, 05:33 PM
  4. What is wrong with my code?
    By connorlm3 in forum What's Wrong With My Code?
    Replies: 8
    Last Post: January 28th, 2013, 05:44 PM
  5. There are something wrong with my code...
    By khanhnq in forum Object Oriented Programming
    Replies: 0
    Last Post: January 13th, 2013, 09:04 PM

Tags for this Thread