Search
 
SCRIPT & CODE EXAMPLE
 

JAVA

java structure example

   class Employee {
       private String name;
       private int code;

   // constructor
   public Employee(String name, int code) {
      this.name = name;
      this.code = code;
   }

       // getter
       public String getName() { return name; }
       public int getCode() { return code; }
       // setter

       public void setName(String name) { this.name = name; }
       public void setCode(int code) { this.code = code; }
    }
    
Employee[] arr = new Employee[100];  // new stands for create an array object
arr[0] = new Employee("Peter", 100); // new stands for create an employee object
arr[1] = new Employee("Mary", 90);
Comment

java structure example


   class Employee {
       private String name;
       private int code;

   // constructor
   public Employee(String name, int code) {
      this.name = name;
      this.code = code;
   }

       // getter
       public String getName() { return name; }
       public int getCode() { return code; }
       // setter

       public void setName(String name) { this.name = name; }
       public void setCode(int code) { this.code = code; }
    }

Comment

java structure

 class Employee {
       private String name;
       private int code;

   // constructor
   public Employee(String name, int code) {
      this.name = name;
      this.code = code;
   }

       // getter
       public String getName() { return name; }
       public int getCode() { return code; }
       // setter

       public void setName(String name) { this.name = name; }
       public void setCode(int code) { this.code = code; }
    }
And when you want to create multi employees, create array just like in C:

Employee[] arr = new Employee[100];  // new stands for create an array object
arr[0] = new Employee("Peter", 100); // new stands for create an employee object
arr[1] = new Employee("Mary", 90);
Comment

PREVIOUS NEXT
Code Example
Java :: java map get value 
Java :: define 2d array in java 
Java :: final variables in java 
Java :: testng with cucumber 
Java :: scrollbar in textarea java 
Java :: how to set edittext color in android 
Java :: && java 
Java :: The JAVA_HOME environment variable is not defined correctly, this environment variable is needed to run this program. 
Java :: += in java 
Java :: java check if class is subclass 
Java :: ascii values to display certain characters in java 
Java :: sorting algorithms in java 
Java :: find power of number in method java 
Java :: java sort array int 
Java :: directory size java 
Java :: imperative programming paradigm example 
Java :: for var i = 0 
Java :: local inner class in java 
Java :: android MediaStore update cache before query 
Java :: ciclo for para percorere duas listas java 
Sql :: mysql create user with remote access 
Sql :: loading local data is disabled mysql 
Sql :: psql kill pid 
Sql :: view column data type sql 
Sql :: postgresql add enum value 
Sql :: UseSqlServer no definition 
Sql :: pl sql escape & 
Sql :: flutter sqlite auto incrementing id primary key 
Sql :: mysql first day of month 
Sql :: delete first row in sql 
ADD CONTENT
Topic
Content
Source link
Name
6+5 =