Java basics: 27th class definition

Source: Internet
Author: User

 

The following section describes how to abstract a class from an object and how to define a class using Java syntax. The class definition includes the Class header definition and the class body definition. 1. Basic Format of Class header definition: Access Controller [other modifier] class name [extends parent class] [implements interface [, interface 2…] 1.1 There are two types of access control operators: public and default. By default, nothing is written. The Access Controller determines where the class can be accessed. If the access control operator is public, it indicates that this class can be used anywhere. If the access control operator of the class is default, this class can only be used in the same package, which will be described later. 1.2 Other controllers mainly include final and abstract. Final indicates that the class is the final class. Abstract indicates that the class is an abstract class. The specific usage is described later. 1.3 classclass is a keyword of the famous class, which must be used by the famous class. 1.4 The class name must comply with the naming rules of Java identifiers. In addition, the class name should meet the following writing habits: N class names are capitalized; n if the class name contains multiple words, each letter is capitalized; n categories use nouns as much as possible; n categories use meaning as much as possible. 1.5 The extends parent class is known as the parent class. The usage is described later. 1.6 [implements interface [, interface 2…] The interface to be implemented is described later. 1.7 The following example shows some famous class headers: public class userpublic class order implements serializableclass orderitempublic Class Customer extends user2. Class body definition a piece of code enclosed in parentheses is used for class body definition, includes the definition of member variables and member methods. The basic format is as follows: {// definition of member variables // definition of member Methods} 2.1 member variables are used to describe the attributes and States of an object and their relationships with other objects. 2.2 The member method is used to describe the object function. Some are used to operate member variables, and some are used to operate other objects. For details about how to define member variables and member methods, refer to the following introduction. Last time: 26th abstract the class from the object next time: 28th member variablesLi xucheng csdn blog: http://blog.csdn.net/javaeeteacher if you want to communicate with me, or become friends with me, please click: http://student.csdn.net/invite.php? U= 124362 & C = 7be8ba2b6f3b6cc5

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.