| | |
JAVA Illegal Start of Expression Error
![]() |
•
•
Join Date: Mar 2006
Posts: 2
Reputation:
Solved Threads: 0
Could someone please help me out. I have an illegal start of an expression error at line 8 in the following code.
package untitled5;
public class Untitled1 {
public static void main(String[] args) {
public static void main(String[] args) {
int start_system, add_modify, add_modify_animal_data, report,
exit_system;
int check = menu();
while (check != 4) {
if (check == 1) {
add_modify_data();
}
else
if (check == 2) {
add_modify_medical_data();
}
else
if (check == 3) {
report();
}
check = menu();
}
exit_system();
System.exit(0);
}
{
public static void start_system() {
System.out.println("Start_system now");
}
}
//sets up the output
public static int menu() {
int check;
String output = "Modify Animal Data" + "\n " +
"1. Add/Modify Animal Data " + "\n" +
"2. Add/modify Meical Data " + "\n" +
"3. Report Section " + "\n" +
"4. Exit " + "\n " + "\n " + " Enter Your Selection:";
String scheck = JOptionPane.showInputDialog(null, output, " ",
JOptionPane.QUESTION_MESSAGE);
check = Integer.parseInt(scheck);
return check;
}
public static void add_modify() {
int check1;
while (check1 != 4) {
if (check1 == 1) {
add_animal_data();
}
else
if (check1 == 2) {
delete_animal_data();
}
else
if (check1 == 3) {
change_animal_data();
}
check1 = menu();
}
exit_system();
System.exit(0);
String output = "Modify Animal Data " + "\n " +
"1. Add Animal Data " + "\n" +
"2. Modify Animal Data " + "\n" +
"3. Change Animal Data " + "\n" +
"4. Exit " + "\n " + "\n " + " Enter Your Selection:";
String scheck = JOptionPane.showInputDialog(null, output, " ",
JOptionPane.QUESTION_MESSAGE);
check1 = Integer.parseInt(scheck);
}
public static void add_modify_medical_data() {
int check2;
while (check2 != 4) {
if (check2 == 1) {
add_medical();
}
else
if (check2 == 2) {
delete_medical();
}
else
if (check2 == 3) {
change_medical();
}
check2 = menu();
}
exit_system();
System.exit(0);
String output = "Modify Medical Data " + "\n " +
"1. Add Medical Data " + "\n" +
"2. Modify Medical Data " + "\n" +
"3. Change Change Data " + "\n" +
"4. Exit " + "\n " + "\n " + " Enter Your Selection:";
String scheck = JOptionPane.showInputDialog(null, output, " ",
JOptionPane.QUESTION_MESSAGE);
check2 = Integer.parseInt(scheck);
}
public static void report() {
System.out.println("in Report");
}
public static void exit_system() {
System.out.println("in exit system");
};
}
}
Thank you
package untitled5;
public class Untitled1 {
public static void main(String[] args) {
public static void main(String[] args) {
int start_system, add_modify, add_modify_animal_data, report,
exit_system;
int check = menu();
while (check != 4) {
if (check == 1) {
add_modify_data();
}
else
if (check == 2) {
add_modify_medical_data();
}
else
if (check == 3) {
report();
}
check = menu();
}
exit_system();
System.exit(0);
}
{
public static void start_system() {
System.out.println("Start_system now");
}
}
//sets up the output
public static int menu() {
int check;
String output = "Modify Animal Data" + "\n " +
"1. Add/Modify Animal Data " + "\n" +
"2. Add/modify Meical Data " + "\n" +
"3. Report Section " + "\n" +
"4. Exit " + "\n " + "\n " + " Enter Your Selection:";
String scheck = JOptionPane.showInputDialog(null, output, " ",
JOptionPane.QUESTION_MESSAGE);
check = Integer.parseInt(scheck);
return check;
}
public static void add_modify() {
int check1;
while (check1 != 4) {
if (check1 == 1) {
add_animal_data();
}
else
if (check1 == 2) {
delete_animal_data();
}
else
if (check1 == 3) {
change_animal_data();
}
check1 = menu();
}
exit_system();
System.exit(0);
String output = "Modify Animal Data " + "\n " +
"1. Add Animal Data " + "\n" +
"2. Modify Animal Data " + "\n" +
"3. Change Animal Data " + "\n" +
"4. Exit " + "\n " + "\n " + " Enter Your Selection:";
String scheck = JOptionPane.showInputDialog(null, output, " ",
JOptionPane.QUESTION_MESSAGE);
check1 = Integer.parseInt(scheck);
}
public static void add_modify_medical_data() {
int check2;
while (check2 != 4) {
if (check2 == 1) {
add_medical();
}
else
if (check2 == 2) {
delete_medical();
}
else
if (check2 == 3) {
change_medical();
}
check2 = menu();
}
exit_system();
System.exit(0);
String output = "Modify Medical Data " + "\n " +
"1. Add Medical Data " + "\n" +
"2. Modify Medical Data " + "\n" +
"3. Change Change Data " + "\n" +
"4. Exit " + "\n " + "\n " + " Enter Your Selection:";
String scheck = JOptionPane.showInputDialog(null, output, " ",
JOptionPane.QUESTION_MESSAGE);
check2 = Integer.parseInt(scheck);
}
public static void report() {
System.out.println("in Report");
}
public static void exit_system() {
System.out.println("in exit system");
};
}
}
Thank you
•
•
Join Date: Aug 2005
Posts: 216
Reputation:
Solved Threads: 8
of course you are. 
You really need to check your combination of open and close brackets. You must have an equal amout of both and you must fallow the java rules for declaration of attributes and methods.
I would recommend picking up a basic java book to learn these rules.
[offtopic]
Arn't the smiles here about the most evil things you've ever seen? The normal smile looks like he just took you for all you're worth.
[/offtopic]

You really need to check your combination of open and close brackets. You must have an equal amout of both and you must fallow the java rules for declaration of attributes and methods.
I would recommend picking up a basic java book to learn these rules.
[offtopic]
Arn't the smiles here about the most evil things you've ever seen? The normal smile looks like he just took you for all you're worth.
[/offtopic]
•
•
•
•
Originally Posted by hooknc
of course you are.
You really need to check your combination of open and close brackets. You must have an equal amout of both and you must fallow the java rules for declaration of attributes and methods.
I would recommend picking up a basic java book to learn these rules.
[offtopic]
Arn't the smiles here about the most evil things you've ever seen? The normal smile looks like he just took you for all you're worth.
[/offtopic]
*Voted best profile in the world*
•
•
Join Date: Jun 2007
Posts: 9
Reputation:
Solved Threads: 0
hi can anyone help me please. I'm having problem with my program. It's only one error illegal starts of expression in public void check (), at line 53. What it is mean?..
import javax.swing.JOptionPane;
//public class waiter{
//public static void main(String [] args)
class waiter
{
private double tab;
public waiter(String name);
{
System.out.println("My name is "+ name +", and i'll be your waiter!");
tab = 0.0;
}
public double priceof(String s);
{
double price;
if (s.equals("Chicken"))
{price = 5.95;}
else
{//burger fries
if (s.equals("burger"))
{price = 4.95; }
else
{price = 1.95;}
}//burger or fries
return price;
}//priceof
public void order(String s)
{
if(s.equals("Chicken"))
{
tab = tab + 5.95;
}// burger fries
else
{//burger fries
if (s.equals("Burger"))
{
tab = tab + 4.95;
}
else
{
tab = tab + 1.95;
}
}//price of
public void check()
{
System.out.println("Please pay $" + tab+",null");
}
}//end of class waiter
public class objects3
{
public static void main(String [] args)
{
waiter ourwaiter;
ourwaiter = new waiter ("Manfred");// makes a waiter object
double x; //to hold price of burger
double y; //varikable to hold price of chicken
x = ourwaiter.priceof("burger");
y = ourwaiter.priceof("chicken");
if (x<y)// buy cheaper product
{
System.out.println("I'll take the burger because it's cheaper");
ourwaiter.order("Burger");
}//burger
else
{
System.out.println("I'll take the chicken. ");
ourwaiter.order("chicken");
}//chicekn
System.out.println("And i'll have fries with that");
ourwaiter.oreder("Fries");
System.out.println("\n eat eat....\n");
ourwaiter.check();
}//main
}//class objects3
import javax.swing.JOptionPane;
//public class waiter{
//public static void main(String [] args)
class waiter
{
private double tab;
public waiter(String name);
{
System.out.println("My name is "+ name +", and i'll be your waiter!");
tab = 0.0;
}
public double priceof(String s);
{
double price;
if (s.equals("Chicken"))
{price = 5.95;}
else
{//burger fries
if (s.equals("burger"))
{price = 4.95; }
else
{price = 1.95;}
}//burger or fries
return price;
}//priceof
public void order(String s)
{
if(s.equals("Chicken"))
{
tab = tab + 5.95;
}// burger fries
else
{//burger fries
if (s.equals("Burger"))
{
tab = tab + 4.95;
}
else
{
tab = tab + 1.95;
}
}//price of
public void check()
{
System.out.println("Please pay $" + tab+",null");
}
}//end of class waiter
public class objects3
{
public static void main(String [] args)
{
waiter ourwaiter;
ourwaiter = new waiter ("Manfred");// makes a waiter object
double x; //to hold price of burger
double y; //varikable to hold price of chicken
x = ourwaiter.priceof("burger");
y = ourwaiter.priceof("chicken");
if (x<y)// buy cheaper product
{
System.out.println("I'll take the burger because it's cheaper");
ourwaiter.order("Burger");
}//burger
else
{
System.out.println("I'll take the chicken. ");
ourwaiter.order("chicken");
}//chicekn
System.out.println("And i'll have fries with that");
ourwaiter.oreder("Fries");
System.out.println("\n eat eat....\n");
ourwaiter.check();
}//main
}//class objects3
•
•
Join Date: Jun 2007
Posts: 9
Reputation:
Solved Threads: 0
h..i can anyone help me please. I'm having problem with this program. It's only one error illegal starts of expression in public void check (), at line 53. What it is mean?..
import javax.swing.JOptionPane;
class waiter
{
private double tab;
public waiter(String name);
{
System.out.println("My name is "+ name +", and i'll be your waiter!");
tab = 0.0;
}
public double priceof(String s);
{
double price;
if (s.equals("Chicken"))
{price = 5.95;}
else
{//burger fries
if (s.equals("burger"))
{price = 4.95; }
else
{price = 1.95;}
}//burger or fries
return price;
}//priceof
public void order(String s)
{
if(s.equals("Chicken"))
{
tab = tab + 5.95;
}// burger fries
else
{//burger fries
if (s.equals("Burger"))
{
tab = tab + 4.95;
}
else
{
tab = tab + 1.95;
}
}//price of
public void check()
{
System.out.println("Please pay $" + tab+",null");
}
}
public class objects3
{
public static void main(String [] args)
{
waiter ourwaiter;
ourwaiter = new waiter ("Manfred");// makes a waiter object
double x;
double y;
x = ourwaiter.priceof("burger");
y = ourwaiter.priceof("chicken");
if (x<y)// buy cheaper product
{
System.out.println("I'll take the burger because it's cheaper");
ourwaiter.order("Burger");
}
else
{
System.out.println("I'll take the chicken. ");
ourwaiter.order("chicken");
}
System.out.println("And i'll have fries with that");
ourwaiter.oreder("Fries");
System.out.println("\n eat eat....\n");
ourwaiter.check();
}
}
import javax.swing.JOptionPane;
class waiter
{
private double tab;
public waiter(String name);
{
System.out.println("My name is "+ name +", and i'll be your waiter!");
tab = 0.0;
}
public double priceof(String s);
{
double price;
if (s.equals("Chicken"))
{price = 5.95;}
else
{//burger fries
if (s.equals("burger"))
{price = 4.95; }
else
{price = 1.95;}
}//burger or fries
return price;
}//priceof
public void order(String s)
{
if(s.equals("Chicken"))
{
tab = tab + 5.95;
}// burger fries
else
{//burger fries
if (s.equals("Burger"))
{
tab = tab + 4.95;
}
else
{
tab = tab + 1.95;
}
}//price of
public void check()
{
System.out.println("Please pay $" + tab+",null");
}
}
public class objects3
{
public static void main(String [] args)
{
waiter ourwaiter;
ourwaiter = new waiter ("Manfred");// makes a waiter object
double x;
double y;
x = ourwaiter.priceof("burger");
y = ourwaiter.priceof("chicken");
if (x<y)// buy cheaper product
{
System.out.println("I'll take the burger because it's cheaper");
ourwaiter.order("Burger");
}
else
{
System.out.println("I'll take the chicken. ");
ourwaiter.order("chicken");
}
System.out.println("And i'll have fries with that");
ourwaiter.oreder("Fries");
System.out.println("\n eat eat....\n");
ourwaiter.check();
}
}
As Jwenting mentioned, you need to start a new thread with your question and place your code between code tags to make it more readable. See the post at the top of the forum about code tags.
An illegal start of expression means that you have misformatted your code and it cannot be parsed correctly. This would include things like missing braces or parens, declaring a method within a method, missing semi-colon, etc.
An illegal start of expression means that you have misformatted your code and it cannot be parsed correctly. This would include things like missing braces or parens, declaring a method within a method, missing semi-colon, etc.
![]() |
Similar Threads
- Illegal start of expresion (Java)
- illegal start of expression (Java)
- Fibonacci Recursion - Illegal Start of expression! (Java)
- illegal start of expression (Java)
- Why illegal start of expression error? (Java)
- illegal start of expression (Java)
Other Threads in the Java Forum
- Previous Thread: special symbols
- Next Thread: Calendar applets Help
| Thread Tools | Search this Thread |
6 actuate android api applet application applications array arrays automation balls bank binary bluetooth bold business c++ chat class clear client code codesnippet collections component coordinates database defaultmethod development dice doctype dragging ebook eclipse educational error file formatingtextintooltipjava fractal froglogic game givemetehcodez graphics gui hql html ide ideas image infinite ingres integer intersect invokingapacheantprogrammatically j2me java javaexcel javaprojects jni jpanel jtextarea julia linux list map method methods mobile mysql netbeans openjavafx parameter php problem program programming project recursion repositories scanner scrollbar sell server set sms sort sorting sql sqlserver state storm string sun superclass swing swt threads tree websites windows






