Results 1 to 11 of 11
  1. #1
    Tekila is offline Member
    Join Date
    Feb 2011
    Posts
    6
    Rep Power
    0

    Default Illegal start of expression

    I'm getting "Illegal start of expression" error at the last line of the code
    Java Code:
    import javax.swing.*;
    public class Numeros {
    	public static void main (String args[]) {
    		int a, b, c;
    
    		a = Integer.parseInt(JOptionPane.showInputDialog("Digite o primeiro número"));
    		b = Integer.parseInt(JOptionPane.showInputDialog("Digite o segundo número"));
    		c = Integer.parseInt(JOptionPane.showInputDialog("Digite o terceiro número"));
    
    		JOptionPane.showMessageDialog("Os números digitados foram: " +a+ " " +b+ " " +c+);
    	}
    }
    the error is in this line
    Java Code:
    JOptionPane.showMessageDialog("Os números digitados foram: " +a+ " " +b+ " " +c+);
    Thanks

  2. #2
    subith86 is offline Senior Member
    Join Date
    Jan 2011
    Location
    Bangalore, India
    Posts
    102
    Rep Power
    0

    Default

    First of all Java API says this :
    showMessageDialog(Component parentComponent, Object message)
    Here you try to give only one argument.

    One more. Remove the "+" in the last line after "c"

  3. #3
    Tekila is offline Member
    Join Date
    Feb 2011
    Posts
    6
    Rep Power
    0

    Default

    Quote Originally Posted by subith86 View Post
    First of all Java API says this :
    showMessageDialog(Component parentComponent, Object message)
    Here you try to give only one argument.

    One more. Remove the "+" in the last line after "c"
    Thanks, but i´m using JCreator LE, and i´m pretty new to Java stuff... so I kinda don´t know what an argument is... thanks for the advice of the other error.

  4. #4
    Junky's Avatar
    Junky is offline Grand Poobah
    Join Date
    Jan 2011
    Location
    Dystopia
    Posts
    3,800
    Rep Power
    7

    Default

    Argument/parameter is the values inside the round brackets that you pass to a method.

    Java Code:
    System.out.println("hello");
    The String "hello" is the argument to the println method.

  5. #5
    Join Date
    Feb 2011
    Posts
    8
    Rep Power
    0

    Default

    Have you tried this?

    Java Code:
    JOptionPane.showMessageDialog([COLOR="Red"]null[/COLOR], "Os números digitados foram: " +a+ " " +b+ " " +c);

  6. #6
    Tekila is offline Member
    Join Date
    Feb 2011
    Posts
    6
    Rep Power
    0

    Default

    Quote Originally Posted by killasaurus tex View Post
    Have you tried this?

    Java Code:
    JOptionPane.showMessageDialog([COLOR="Red"]null[/COLOR], "Os números digitados foram: " +a+ " " +b+ " " +c);
    Yeah i did, no results though.

    Thanks

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

    Default

    Don't ignore reply #2; it tells you exactly what is wrong with your code.

    kind regards,

    Jos
    cenosillicaphobia: the fear for an empty beer glass

  8. #8
    Tekila is offline Member
    Join Date
    Feb 2011
    Posts
    6
    Rep Power
    0

    Default

    Quote Originally Posted by JosAH View Post
    Don't ignore reply #2; it tells you exactly what is wrong with your code.

    kind regards,

    Jos
    I tried but it didn´t work.

    Do I need to put something in place of "Component parentComponent"?

    Thanks

  9. #9
    Junky's Avatar
    Junky is offline Grand Poobah
    Join Date
    Jan 2011
    Location
    Dystopia
    Posts
    3,800
    Rep Power
    7

    Default

    Quote Originally Posted by Tekila View Post
    I tried but it didn´t work.
    Well, from that wealth of information I'm sure someone knows what the problem is. Or perhaps you can post the latest version of your code and fully explain what happens. Error messages? Then copy and paste the EXACT error message. Incorrect behviour? Then explain what does happen and what you want to happen instead.

  10. #10
    Tekila is offline Member
    Join Date
    Feb 2011
    Posts
    6
    Rep Power
    0

    Default

    Quote Originally Posted by Junky View Post
    Well, from that wealth of information I'm sure someone knows what the problem is. Or perhaps you can post the latest version of your code and fully explain what happens. Error messages? Then copy and paste the EXACT error message. Incorrect behviour? Then explain what does happen and what you want to happen instead.
    Ok, here´s the exact code:
    Java Code:
    import javax.swing.*;
    public class Numeros {
    	public static void main (String args[]) {
    		int a, b, c;
    
    		a = Integer.parseInt(JOptionPane.showInputDialog("Digite o primeiro número"));
    		b = Integer.parseInt(JOptionPane.showInputDialog("Digite o segundo número"));
    		c = Integer.parseInt(JOptionPane.showInputDialog("Digite o terceiro número"));
    
    		JOptionPane.showMessageDialog(null,"Os números digitados foram: " +a+ " " +b+ " " +c);
    	}
    }
    and the error is :
    illegal start of expression - line 10

  11. #11
    Tekila is offline Member
    Join Date
    Feb 2011
    Posts
    6
    Rep Power
    0

    Default

    Solved, the problem was an extra '+' after c in line 10.

    thx everybody

Similar Threads

  1. Illegal start of expression
    By Basit56 in forum New To Java
    Replies: 2
    Last Post: 08-18-2009, 10:12 AM
  2. Illegal Start of an Expression
    By ddatta8 in forum New To Java
    Replies: 3
    Last Post: 12-20-2008, 09:40 PM
  3. Illegal Start of Expression
    By vince425 in forum New To Java
    Replies: 3
    Last Post: 10-18-2008, 08:41 AM
  4. illegal start of expression
    By razmyasdfg in forum CLDC and MIDP
    Replies: 2
    Last Post: 07-27-2008, 11:44 PM
  5. Illegal start of expression
    By gabriel in forum New To Java
    Replies: 2
    Last Post: 08-01-2007, 06:09 PM

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
  •