0

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;
	}	
}
}

Edited by masijade: added code tags

4
Contributors
3
Replies
4
Views
7 Years
Discussion Span
Last Post by stultuske
0

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

0

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.

0

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

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.