Win a copy of OCP Java SE 8 Programmer II Exam Study Guide this week in the OCP forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

JOptionPane problems  RSS feed

 
Gunslinger
Ranch Hand
Posts: 165
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi all,

If mySB is a stringbuffer, what is wrong with the following declaration? Error messages are:
C:\Documents and Settings\Owner.Mynotebook\Ch5ItIs\src\ch5itis\Chapter7Strings.java:29: <identifier> expected
JOptionPane.showMessageDialog(null, "The user ID is " + mySB);
C:\Documents and Settings\Owner.Mynotebook\Ch5ItIs\src\ch5itis\Chapter7Strings.java:29: illegal start of type
JOptionPane.showMessageDialog(null, "The user ID is " + mySB);
2 errors

 
Sheriff
Posts: 11343
Java Mac Safari
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Originally posted by Patrick Brooks:
...what is wrong with the following declaration? ...


It's not a declaration -- it's a method call. Nothing is wrong that that line of code, but it needs to be inside the body of a method.
 
James Brooks
Gunslinger
Ranch Hand
Posts: 165
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
It was inside valid code, but when I closed NetBeans and reopened, it compiled and ran just fine. Strange.


-Patrick
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!