Small white Java Learning path "Class of No-parameter method"

Source: Internet
Author: User

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"

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.