Java class properties
There are a hero's name, blood, armor and so the state of
the state is called a class of property
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
public class Hero {
String name; //姓名
float hp; //血量
float armor; //护甲
int moveSpeed; //移动速度
}
Step 2: Attribute Name
In general property names are lowercase
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; //移动速度
}