JAVA brief description

 JAVA is an object-oriented programming language, which is characterized by encapsulation, inheritance, polymorphism. The so-called object-oriented, that is an idea, referred to as OOP thinking. That said, a bit vague. Specific features is the same type of thing extracted, and to describe JAVA language.
To give an example,

    public the Person class the extends Animal {         // Name         Private String name;         // Age         Private int Age;         // Height         Private Double Hight;         // weight         Private Double weight;         public String getName () {             return name;         }         public the setName void (String name) {             this.name = name;         }         public int getAge () {             return Age;         }         public void the setAge (int Age) {             this.age = Age;
    








    



    



    



    


        }
    
        public double getHight() {
            return hight;
        }
    
        public void setHight(double hight) {
            this.hight = hight;
        }
    
        public double getWeight() {
            return weight;
        }
    
        public void setWeight(double weight) {
            this.weight = weight;
        }
         
    }
    class Animal {
    
        public void eat() {
            System.out.println("吃");
        }
    }
This defines a man, describing him has a name, age, height, weight properties, which are private, others can only access and can not have. Here are accessible entrance, it can get to get by calling its methods. Here reflects the characteristics of the package, it is to privatize property of the object and provide a way to access the property. Person inherited Animal, Animal's eat it can have functions. This reflects the inherited characteristics of JAVA language, this feature can make the code simple, and can reduce redundant code and improve efficiency. The last feature of polymorphism, its meaning is the parent class reference point to a subclass object. what does it mean? Is that when I create a subclass object can be used to define parent class, such as Animal p = new Person; objects created can either call their own methods, non-private methods of the parent class can be called.

JAVA is an object-oriented programming language, which is characterized by encapsulation, inheritance, polymorphism. The so-called object-oriented, that is an idea, referred to as OOP thinking. That said, a bit vague. Specific features is the same type of thing extracted, and to describe JAVA language. To give an example,
public the Person class the extends Animal {
// name private String name; // age of private int age; // height private double hight; // Double weight weight Private;
public String getName () {return name;}
public the setName void (String name) {name = this.name;}
public int getAge () {return Age;}
public void the setAge (Age int) = {this.age Age;}
public Double getHight () {return Hight;}
public setHight void (Double Hight) = {this.hight Hight;}
public Double getWeight () {return weight;}
public void setWeight (Double weight) = {weight this.weight;}} class Animal {
public void eat () {System.out.println ( "eat");}} 1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950 defined here as a person, has described his name, age, height, weight properties, which are private, others can only access, You can not have. Here are accessible entrance, it can get to get by calling its methods. Here reflects the characteristics of the package, it is to privatize property of the object and provide a way to access the property. Person inherited Animal, Animal's eat it can have functions. This reflects the inherited characteristics of JAVA language, this feature can make the code simple, and can reduce redundant code and improve efficiency. The last feature of polymorphism, its meaning is the parent class reference point to a subclass object. what does it mean? Is that when I create a subclass object can be used to define parent class, such as Animal p = new Person; objects created can either call their own methods, non-private methods of the parent class can be called. ---------------- Disclaimer: This article is the original article CSDN bloggers "axiaomaguohe", and follow CC 4.0 BY-SA copyright agreement, reproduced, please attach the original source link and this statement. . Original link: https: //blog.csdn.net/axiaomaguohe/article/details/104118591

Published 18 original articles · won praise 0 · Views 132

Guess you like

Origin blog.csdn.net/axiaomaguohe/article/details/104130062