java - Having a lot of trouble; illegal start of expression -


i'm new computer programming -- having literally started course little under 6 weeks ago -- , i'm having trouble illegal starts of expressions in netbeans.

the whole code goes follows(since don't know start):

public class employees {     /**      * @param args command line arguments      */     public static void main(string[] args) {         // todo code application logic here         public class employee          //properties         private string name;         private string id;         private string salary;          //constructor         public employee (string name, string address, string dob) {             this.name = name;             this.id = id;             this.salary = salary;         }          //method print details on employees         public void printdetails() {             system.out.println("employee name: " +this.name);             system.out.println("id: "+ this.id);             system.out.println("annual salary: " + this.salary);         }     } } 

you cannot declare class (public class employee) within method declaration (public static void main(string[] args) {).

best move declaration of class employee own file (employee.java). if don't want move different file, can move end of existing file. have declare private instead of public then.

or can make 1 class this:

public class employees {     /**      * @param args command line arguments      */     public static void main(string[] args) {         employees employee = new employees("name", "address", "dob");         employee.printdetails();     }      //properties     private string name;     private string id;     private string salary;      //constructor     public employees (string name, string address, string dob) {         this.name = name;         this.id = id;         this.salary = salary;     }      //method print details on employees     public void printdetails() {         system.out.println("employee name: " +this.name);         system.out.println("id: "+ this.id);         system.out.println("annual salary: " + this.salary);     } } 

Comments

Popular posts from this blog

1111. appearing after print sequence - php -

java - WARN : org.springframework.web.servlet.PageNotFound - No mapping found for HTTP request with URI [/board/] in DispatcherServlet with name 'appServlet' -

Ruby on Rails, ActiveRecord, Postgres, UTF-8 and ASCII-8BIT encodings -