Object-oriented textbook series (two) - properties Java classes

Object-oriented textbook series (two) - properties Java classes

More, click here to learn, sign up for

A hero name, blood, etc. armor state
these state attributes of a class called
Step 1: Type attribute
Step 2: Attribute Name

Step 1: type attribute
type attribute may be a primitive type, such as integer int, float float
may be a class type, such as string String

Please refer to other types of basic types of sections

public class Hero {
    String name; //姓名
    float hp; //血量
    float armor; //护甲
    int moveSpeed; //移动速度
}

Step 2: attribute name
attribute names are in general lower case
such as name
if there is more than one word, the word behind the first letter capitalized
, such as moveSpeed
property is also variable, so it is necessary to meet the naming of variables

public class Hero {
    String name; //姓名
    float hp; //血量
    float armor; //护甲
    int moveSpeed; //移动速度
}

More, CLICK HERE

Published 32 original articles · won praise 182 · views 10000 +

Guess you like

Origin blog.csdn.net/weixin_44092440/article/details/102961994