Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

What are object invocation member variables and member instance methods in java

2025-02-25 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >

Share

Shulou(Shulou.com)06/03 Report--

This article shows you what the object invocation member variables and member instance methods are in java. The content is concise and easy to understand, which will definitely brighten your eyes. I hope you can get something through the detailed introduction of this article.

Use objects to access members of a class:

Object name. Member variable

Object name. Member method ()

Default values for member variables:

Specific example code:

Public class StudentTest_01 {public static void main (String [] args) {/ / create object format, class name object name = new class name (); / / No parameter use method Student S2 = new Student (); s2.setName ("thousand fathom 1"); s2.setAge (25); System.out.println ("name:" + s2.getName ()); System.out.println ("Age:" + s2.getAge ()) System.out.println ("-"); / / use method Student s = new Student ("thousand fathom 2", 23) with parameters; System.out.println ("name:" + s.getName ()); / / null System.out.println ("age:" + s.getAge ()); / / 0 System.out.println ("-"); / / call member method s.study (); s.eat () }}

The above content is what are the object call member variables and member instance methods in java. Have you learned the knowledge or skills? If you want to learn more skills or enrich your knowledge reserve, you are welcome to follow the industry information channel.

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Development

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report