Home > Archive > Java Help > April 2007 > question code of java
You are viewing an archived Text-only version of the thread.
To view this thread in it's original format and/or if you want to reply to
this thread please [click here]
| Author |
question code of java
|
|
|
| Hi , how are you , i need your help !I wrote a java application and it
appears an error such as
'cannot find symbol class format '.
The code is :
//NameDialog.java
//Basic input with a dialog box
import javax.swing.JOptionPane;
public class NameDialog{
public static void main(String[] args){
//prompt user to enter name
String name=JOptionPane.showInputDialog("What is your name?");
//create the message
String message=new String.format("Welcome,%s,to Java
programming",name);
//display the message to welcome the user by name
JOptionPane.showMessageDialog(null,message);
}//end main
}//end class NameDialog
Could you give me your valuable help please ?I will appreciate it very
much!
| |
| Ian Wilson 2007-04-19, 8:07 am |
| mak wrote:
> Hi , how are you , i need your help !I wrote a java application and it
> appears an error such as
> 'cannot find symbol class format '.
> The code is :
> //NameDialog.java
> //Basic input with a dialog box
> import javax.swing.JOptionPane;
> public class NameDialog{
> public static void main(String[] args){
> //prompt user to enter name
> String name=JOptionPane.showInputDialog("What is your name?");
> //create the message
> String message=new String.format("Welcome,%s,to Java
> programming",name);
You appear to be confusing two different things: a constructor and a
static method.
new String();
String.format(format, args);
Try omitting the "new"
String message=String.format(
"Welcome,%s,to Java programming", name);
> //display the message to welcome the user by name
> JOptionPane.showMessageDialog(null,message);
>
> }//end main
> }//end class NameDialog
>
>
> Could you give me your valuable help please ?I will appreciate it very
> much!
>
|
|
|
|
|