day06-面向对象-类的标准代码JavaBean的规范和快捷键

This commit is contained in:
2026-01-19 13:45:43 +08:00
parent b9ec239980
commit a532e17fab

View File

@@ -0,0 +1,55 @@
package com.inmind.object01;
//标准的javaBean
public class Car {
//属性
private String brand;
private double price;
private String color;
//alt+insert:快速自动生成构造方法getset方法等一系列代码注意功能Fn
//构造方法
public Car() {//无参构造
}
public Car(String brand) {//有参构造
this.brand = brand;
}
public Car(String brand, double price, String color) {//满参构造
this.brand = brand;
this.price = price;
this.color = color;
}
//get/set方法
public String getColor() {
return color;
}
public void setColor(String color) {
this.color = color;
}
public String getBrand() {
return brand;
}
public void setBrand(String brand) {
this.brand = brand;
}
public double getPrice() {
return price;
}
public void setPrice(double price) {
this.price = price;
}
//上面的代码固定的标准的javaBean增加其他的一些成员方法
public void study() {
System.out.println(brand+price+color);
}
}