Please help, as I do not know what I have done wrong. Error: illegal start of expression, and ; expected.

import java.util.ArrayList;
import java.util.List;

public class Employee
{

public static void main ( String args [])
{
	
   	//unique identifier
	int empID;
	String firstName;
	String lastName;
	double salary;
	//not sure if u want to model as just a string or as another entity
	//the reason is you may have more than one employee leaving in same address
	String address;
	String address2;
	String employeeType;
	
	List<PaySlip> payslips = new ArrayList<PaySlip>();
	Employee[] employeeList = new Employee [100];
		
	public Employee(int empID, String firstName, String lastName, double salary,
			String address, String address2, String employeeType)
	
	{
		super();
		this.empID = empID;
		this.firstName = firstName;
		this.lastName = lastName;
		this.salary = salary;
		this.address = address;
		this.address2 = address2;
		this.employeeType = employeeType;
	}

	public EmployeeType 
	{
		CONTRACTOR;
		PERMANENT;
	}	
}
}

Recommended Answers

All 3 Replies

It looks as though you have simply wrapped the entirety of your class definition with the main method declaration. Why?

Learn about Object Oriented Programming and then tackle this program with a Driver and Object. When people shift from non-OOP to OOP they often are used to placing everything inside the main() method. Study OOP a bit more and the proper code for this should become apparent; for instance, you can't use a "this" reference in a static method like main. The ; expected is probably a minor syntax error.

Please help, as I do not know what I have done wrong. Error: illegal start of expression, and ; expected.

public EmployeeType 
	{
		CONTRACTOR;
		PERMANENT;
	}

not only do you write all your methods within the main, which you shouldn't, you're trying to write a constructor for EmployeeType within the Employee class.
and what exactly are CONTRACTOR and PERMANENT? I doubt your compiler will recognize these as well

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.