Define name, gender, age, and then assign values, and create an object call method output name, gender, age
/**
*
* Public : Represents the access modifier
* Class : Identification of Classes
* Student: class name
* method name first letter lowercase, remaining after the first letter of the word capital
* Pascal: First Letter Capital
* Camel Name Method: Method name first letter lowercase, the remainder of the first letter of the word capital
*/
Public classstudent{//Package TypeString name;//nameChaar sex;//Sex intAge//Age//Displaying information methods Public voidshowstudent () {System.out.println ("entered the Showstuden method T"); System.out.println ("Name:" +name+ "\ T Gender:" +sex+ "\ T Age:" +Age ); } //The object used to create the class, then assigns a value to the property, invokes the method//Stu is an object of the student class. Public Static voidMain (string[] args) {Student stu=NewStudent ();//create an Object Stu//Assign ValueStu.name;//nameStu.sex;//SexStu.age;//Age//Calling Methodsstu.showstudent (); } }
Class and object instance 1