Java Annotations:
: Single-line comment
/**/: Multiline Comment
/***/:javadoc notes
Grammar:
access modifier return value type method name () {method body} Example: Public voidrun () {System. out. println (""); } Publicstring Robball () {string ball="Ball"; returnBall ; }
The return value of the method:
1. If the method has a return value, the method must return the value using the keyword return, the type of the return value type
return expression, function: Jump out of method, return result
2. If the method does not return a value, the return value type is void
Case: Public classLion {//Color PropertiesString color; intAge ; Public voidrun () {System. out. println ("The Lion is running ."); } Public voidsay () {System. out. println ("The lion was hungry and called to eat."); } PublicString Robball () {System. out. println ("hehe"); String Ball="Volleyball"; returnBall ; } //getting the lion's age Public intGetage () {intAge= -; returnAge ; } } Public classTest { Public Static voidMain (string[] args) {Lion lion=NewLion (); /*Lion.run (); String ball = Lion.robball (); C System.out.println ("Lion is playing:" + ball); System.out.println ("Come back after the method has been executed!") "); */System. out. println (Lion.getage ()); } }
Local variables and member variables:
Different scopes
The scope of a local variable is limited to the method that defines it
The scope of a member variable is visible within the entire class
Different initial values
Java will give the member variable an initial value
Java does not give initial values to local variables
Attention:
Local variables with the same name are not allowed in the same method
In different methods, you can have local variables of the same name
Local variables have higher precedence in the same class when the member variable and local variable have the same name
How to generate Javadoc documents:
1. Using the command line method to generate
2. Using the MyEclipse tool to generate
Small white Java Learning path "Class of No-parameter method"