Results 1 to 4 of 4
Thread: Illegal Start of an Expression
- 12-20-2008, 06:11 PM #1
Member
- Join Date
- Dec 2008
- Posts
- 27
- Rep Power
- 0
Illegal Start of an Expression
Hi,
I am getting an error "Illegal Start of an Expression" for the statement "private welcomeScreen ws = new welcomeScreen();" in the following code. I am new to Java and it will be really great if anyone can help me with this problem.
import java.io.*;
import java.util.*;
private class welcomeScreen
{
private String studID;
private String password;
welcomeScreen(){
studID = "";
password = "";
}
public void display(){
System.out.println("Welcome to the Student Registration System!");
System.out.println("****************************** *************");
System.out.println("Enter student id:");
System.out.println("Enter password:");
}
public void student_authentication(String studID){
return true;
}
}
public class SRS
{
public static void main(String [] args)
{
private welcomeScreen ws = new welcomeScreen();
ws.display();
if (ws.student_authentication == TRUE){
System.out.println("Great!");
}
else ws.display();
}
}
- 12-20-2008, 06:38 PM #2
Errors...
welcomeScreen class has the following error:
Java Code:public [B][COLOR="Red"]void[/COLOR][/B] student_authentication(String studID){ return [COLOR="red"][B]true[/B][/COLOR];}- The above method is returning a boolean but has void in the method declaration
- Get rid of the "private" indentifier in the class declaration
The SRS class has the following errors:
Java Code:[B][COLOR="Red"]private[/COLOR][/B] welcomeScreen ws = new welcomeScreen();
- Get rid of the "private" identifier in the above code
Java Code:ws.student_authentication == TRUE
- TRUE is not defined in the code. If you want to use boolean it should be "true"
- If you're trying to call the student_authentication method, you need to pass it a string (studID) in it's argument. It also returns a boolean
Luck,
CJSLChris S.
Difficult? This is Mission Impossible, not Mission Difficult. Difficult should be easy.
-
1) Why is your welcomeScreen class private? Since it is not an inner class, this class won't be very useful.
2) You cannot declare a private variable within a method including the main method. Get rid of the private access modifier there.
3) If a method returns a boolean result, it must be declared to return boolean, not void.
Several other errors here. Keep working at it and good luck.
- 12-20-2008, 08:40 PM #4
Member
- Join Date
- Dec 2008
- Posts
- 27
- Rep Power
- 0
Similar Threads
-
Illegal Start of Expression
By vince425 in forum New To JavaReplies: 3Last Post: 10-18-2008, 07:41 AM -
illegal start of expression
By razmyasdfg in forum CLDC and MIDPReplies: 2Last Post: 07-27-2008, 10:44 PM -
Illegal Start of an Expression
By David55 in forum CLDC and MIDPReplies: 8Last Post: 11-02-2007, 09:11 PM -
Illegal start of expression
By gabriel in forum New To JavaReplies: 2Last Post: 08-01-2007, 05:09 PM -
Illegal Start of an Expression
By David55 in forum CLDC and MIDPReplies: 0Last Post: 04-20-2007, 05:59 AM


LinkBack URL
About LinkBacks
Reply With Quote
Bookmarks