Results 1 to 4 of 4
  1. #1
    ddatta8 is offline Member
    Join Date
    Dec 2008
    Rep Power

    Default Illegal Start of an Expression

    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.util.*;

    private class welcomeScreen
    private String studID;
    private String password;

    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();


    if (ws.student_authentication == TRUE){
    else ws.display();



  2. #2
    CJSLMAN's Avatar
    CJSLMAN is offline Moderator
    Join Date
    Oct 2008
    Rep Power

    Default 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

    Chris S.
    Difficult? This is Mission Impossible, not Mission Difficult. Difficult should be easy.

  3. #3
    Fubarable's Avatar
    Fubarable is offline Moderator
    Join Date
    Jun 2008
    Blog Entries
    Rep Power


    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.

  4. #4
    ddatta8 is offline Member
    Join Date
    Dec 2008
    Rep Power

Similar Threads

  1. Illegal Start of Expression
    By vince425 in forum New To Java
    Replies: 3
    Last Post: 10-18-2008, 07:41 AM
  2. illegal start of expression
    By razmyasdfg in forum CLDC and MIDP
    Replies: 2
    Last Post: 07-27-2008, 10:44 PM
  3. Illegal Start of an Expression
    By David55 in forum CLDC and MIDP
    Replies: 8
    Last Post: 11-02-2007, 09:11 PM
  4. Illegal start of expression
    By gabriel in forum New To Java
    Replies: 2
    Last Post: 08-01-2007, 05:09 PM
  5. Illegal Start of an Expression
    By David55 in forum CLDC and MIDP
    Replies: 0
    Last Post: 04-20-2007, 05:59 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts