Java supports the concepts of the following classes and objects:
Polymorphism, inheritance, encapsulation, abstraction, class, object, instance, method.
Like books, can also be divided into Chinese books, math books, history books and so on, each book has a different content.
An example of a simple employee:
The employee class has four member variables: name, age, designation, and salary. The class explicitly declares a constructor method that has only one parameter.
public class Test {public static class employee{string Name;int age; String design;double salary;public Employee (string name) {This.name=name;} public void Setage (int.) {this.age=age;} public void Setdsign (String des) {this.design=des;} public void Setsalary (double salary) {this.salary=salary;} public void Printemployee () {System.out.println ("Name" +name); System.out.println ("Age" +age); System.out.println ("Designtion" +design); System.out.println ("Salary" +salary);} public static void Main (String args[]) {Employee Emp1=new employee ("Zhang San"); Employee Emp2=new Employee ("John Doe"), Emp1.setage, Emp1.setdsign ("Program Ape"), Emp1.setsalary (10000); Emp1.printemployee () ; emp2.setage; emp2.setdsign ("Small program Ape"); Emp2.setsalary (8000); Emp2.printemployee ();}}
Operation Result:
"Good programmer training Camp" Java classes and objects