Getting Started with Java Classes and Objects Learning Day

/ * 
* Class object is an instance of * three basic features of object-oriented: encapsulation, inheritance, polymorphism, the basic structure of the class *: properties, methods, constructors, * capitalized class name, the file must be consistent with, use hump nomenclature * constructor name must be consistent with the class name, return type can not, can not have a return value * * * / public class DemoClass { public static void main (String [] args) { } } // create a standard Student class // standard Student class contains four sections // Private modified property, and there are no parameters for each constructor a reference, each comprising a pair of attribute Getter / Setter methods class Student { Private String name; // Private modified properties and in the present method can be called directly inside the class Private int Age; // constructor with no arguments publicStudent () {} // All Parameters constructor public Student (String name, int {Age) this .name = name; // inside the class, class attributes and parameter names are the same, this keyword class attribute to use this .age = Age; } public String getName () { return name; } public void the setName (String name) { the this .name = name; } public int getAge () { return Age; } public void the setAge ( int Age) { the this.age = age; } }

 

Guess you like

Origin www.cnblogs.com/vxiao2/p/11479195.html