Several simple call relationships and methods of "Java Foundation"

Source: Internet
Author: User

Go directly to the code.

1 classLesson4ab2 //The public -decorated method under the same class, A, B, can call each other3 {4      Public voidA ()5     {6B ();//equivalent to this. B ();7     }8      Public voidB ()9     {TenA ();//equivalent to this. A (); One     } A } - classlesson4c - //methods for public modification that exist in different classes C Call B the { -      Public voidC () -     { -Lesson4ab lab=Newlesson4ab (); + lab.b (); -         //the top and bottom two methods are equivalent and can be called +         NewLesson4ab (). B (); A     } at } - classLESSON4DE - //static methods in the same class call each other with non-static methods.  - { -      Public Static voidD ()//modify with static, belong to class member -     { in         //E ();//Error: Unable to reference a non-static method from a static context E () -         //"Popular saying is static does not refer to non-static" to  +         //This . E ();//Error: Unable to reference the non-static variable from the static context this -         //"The popular saying is static and this cannot coexist" the  *         NewLESSON4DE (). E ();//through $         //Public void E () does not have a static decoration, belongs to an object, and can only be invoked with an objectPanax Notoginseng     } -      Public voidE ()//No static modifier, belongs to Object the     { +D ();//equivalent to this. D (); A         //object can invoke a class member the     } + } - classLesson4 $ { $      Public Static voidMain (string[] args) -     { -System.out.println ("May happy!"); the     } -}

I am a small rookie, the above for online self-study experience summary, if there are errors please point out. Novice children shoes A lot of exchanges, the great God of many guidance. I wish you all a happy life.

Several simple call relationships and methods of "Java Foundation"

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.