This week's book giveaways are in the Java EE and JavaScript forums.
We're giving away four copies each of The Java EE 7 Tutorial Volume 1 or Volume 2(winners choice) and jQuery UI in Action and have the authors on-line!
See this thread and this one for details.
The moose likes Beginning Java and the fly likes getting answer to pop up in dialog box... Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of The Java EE 7 Tutorial Volume 1 or Volume 2 this week in the Java EE forum
or jQuery UI in Action in the JavaScript forum!
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "getting answer to pop up in dialog box..." Watch "getting answer to pop up in dialog box..." New topic
Author

getting answer to pop up in dialog box...

Brandi Love
Ranch Hand

Joined: Sep 19, 2003
Posts: 133
I'm writing a simple program in which I want the answer to an equation to pop up in a dialog box. All I need to pop up is the value of y. Here is my attempt, and the errors. Any suggestions?
//Brandi Love
//Computer Science I Lab, Section 113
//Socks Problem
public class Socks
{
public static void main(String[] args)
{
int x, y;
x = 5 + 2;

y = x + 1;
JOptionPane.showMessageDialog(null,"value of y: " + y, ", "Sample", JOptionPane.INFORMATION_MESSAGE);

System.exit(0);
}
}



Stan James
(instanceof Sidekick)
Ranch Hand

Joined: Jan 29, 2003
Posts: 8791
Looks like just the wrong number of quote marks. The compiler points to Sample being incorrect, so the error is somewhere right before that. Look at each of your parameters ... see if one jumps out at you as missing a quote. (I'm resisting giving you the actual answer - you'll enjoy it much more if you spot it!)


A good question is never answered. It is not a bolt to be tightened into place but a seed to be planted and to bear more seed toward the hope of greening the landscape of the idea. John Ciardi
Brandi Love
Ranch Hand

Joined: Sep 19, 2003
Posts: 133
Okay so I resolved the whole quotes problem I'm still getting an error though, with the pointer pointing to the J in JOptionPane. Any idea why?

[ September 21, 2003: Message edited by: Brandi Love ]
Brandi Love
Ranch Hand

Joined: Sep 19, 2003
Posts: 133
Nevermind, I've got it now (I'm so proud of myself, I'm actually starting to understand this ) Thanks for the assistance.
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: getting answer to pop up in dialog box...