Some of the basic concepts in Java

Source: Internet
Author: User

This is the second time I read the Java book, I feel that the second pass is really a lot of harvest. I recorded some of my own knowledge that I had not noticed before.

1, first the constructor, public Employee (String n,double s)

{Name (instance field) =n (parameter variable);

Salary (instance domain) =s (parametric variable);

The constructor name is the same as the class name and the first letter is capitalized. The first letter of the name of a method is capitalized in the first letter of the second word.

The constructor is able to construct and initialize the object: New Employe () Construction object (employ) staff (variable value) =new Employee (); initialization

2, static variables, static fields, static methods and static classes: static methods and static variables can be accessed directly through the (class. method) without having to construct the object on the row.

Note: Static methods cannot call their non-static methods, non-static domains

3, the accessor (get+ noun), the modifier (set+ noun (Salary)), the accessor is the variable required to access the object, and the change is the line to change the amount of modification.

Some of the basic concepts in Java

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.