Java keywords:
A, some Java in a specific meaning, and used to do special use of the word is called a keyword, to represent a data type or structure;
b, all the keywords in Java are lowercase;
C, goto and const, although never used, are also reserved as Java keywords;
D, keywords cannot be used as variable names, method names, class names, package names, and parameters;
Currently there are 50 Java keywords:
Final static This super public protected default Privatevolatile synchronized abstract assert Boolean break byte continue Case catch Char Class const Double does extends else float for goto long if implements import native new null instanceof int Interface package return short STRICTFP switch while void throw throws transient try
1. This keyword
Represents a property in a class; You can use this to invoke the constructor method of this class; This represents the current object
(1) Represents a property in a class
[Java]View plain copy public class Person {private String name; private int age; The parameters that String name and name pass over when instantiated, THIS.name represents the properties of the class public person (String name, int age) {this.name = name;//is Property Assignment This.age = age for class; Public String toString () {return "name:" +this.name+ "Age:" +this.age; } }[Java]View plain copy public class ThisDemo01 {public static void main (string[] args) {person per = new Perso N ("John", 20); System.out.println (per); Output results:
[Java] view plain Copy name: John Age: (2) This calls the constructor method of this class
Note: A, the use of this call to the constructor method can only be placed in the first row of the construction method; B, there is at least one constructor in the program that does not use this to invoke the other construction methods, typically using the parameterless construction method as an exit
[Java] View Plain copy public class person { private string name; private int age; // Define the parameterless construction method public person () { system.out.println ("A new person object is instantiated"); } public person (string name, int age) { this ()//The parameterless constructor method for person is called this.name = name;//for the properties of a class this.age = age; } public string tostring () { return "Name:" +this.name+ "Age:" +this.age; } }