Logo 
Search:

Java Forum

Ask Question   UnAnswered
Home » Forum » Java       RSS Feeds

String Parse Question

  Asked By: Ketan    Date: Nov 03    Category: Java    Views: 756
  

import javax.swing.JOptionPane;
import java.text.*;
public class SimpleSignInExample{
public static void main(String[] args){
String choice = "";
try{
while (!(choice.equalsIgnoreCase("x"))){

String userName = null;
String userPassword = null;
String userAccount = null;

String userInfo = null;

String inputString = JOptionPane.showInputDialog(null,
"Enter last name, account and password (separate each
with a comma): ", JOptionPane.PLAIN_MESSAGE);
String message = "Last name: " + (userName) + "\n"
+ "Account: " + (userAccount) + "\n"
+ "Password: " + (userPassword) + "\n\n"
+ "To continue, press Enter.\n"
+ "To exit, enter 'x': ";
choice = JOptionPane.showInputDialog(null,
message, "Input", JOptionPane.PLAIN_MESSAGE);
}
}
catch(NullPointerException e){
System.exit(0);
}
System.exit(0);
}


When I compile I get 3 errors:

C:\java\bin\SinpleSignInExample.java:30: '}' expected
}
^
C:\java\bin\SinpleSignInExample.java:3: class SimpleSignInExample is
public, should be declared in a file named SimpleSignInExample.java
public class SimpleSignInExample{
^
C:\java\bin\SinpleSignInExample.java:15: cannot resolve symbol
symbol : method showInputDialog (<*>,java.lang.String,int)
location: class javax.swing.JOptionPane
String inputString = JOptionPane.showInputDialog(null,
^
3 errors

Process completed.

I am lost.. can anyone help?

Share: 

 

3 Answers Found

 
Answer #1    Answered By: Hayden Evans     Answered On: Nov 03

you close your main function but not the class

 
Answer #2    Answered By: Sairah Hashmi     Answered On: Nov 03

1) Your file is named incorrectly. It should be "Simple", not "Sinple".

2) You are missing a bracket ("}") at the end of the file. Put it on the last
line.

3) Add a fourth parameter to the call to showInputDialog (just like in your
second
call to showInputDialgo) with the name of the window in it.

 
Answer #3    Answered By: Rosa Reynolds     Answered On: Nov 03

1) The First Error u have to find out by ur self as
the i dont have the entire lines of codes.
2) The 2 error is due to u have to Save this program
in a file named "SimpleSignInExample.java" because u
mentioned it as public  and any class  declared as
public should be saved in file with the class name.
3)The 3 error u have to find the suitable class for
which the method belongs.

 
Didn't find what you were looking for? Find more on String Parse Question Or get search suggestion and latest updates.




Tagged: