java structure example

Solutions on MaxInterview for java structure example by the best coders in the world

showing results for - "java structure example"
Tobin
20 May 2020
1   class Employee {
2       private String name;
3       private int code;
4
5   // constructor
6   public Employee(String name, int code) {
7      this.name = name;
8      this.code = code;
9   }
10
11       // getter
12       public String getName() { return name; }
13       public int getCode() { return code; }
14       // setter
15
16       public void setName(String name) { this.name = name; }
17       public void setCode(int code) { this.code = code; }
18    }
19    
20Employee[] arr = new Employee[100];  // new stands for create an array object
21arr[0] = new Employee("Peter", 100); // new stands for create an employee object
22arr[1] = new Employee("Mary", 90);
23