构造
初始化
缺省构造-----无参构造方法
方法重载
方法重载
,指
同一
个类中
多个方法
- 方法名相同
- 参数列表不同
- 与返回值、访问修饰符无关
例如:
public void avg(int a,int b){
System.out.println((a+b)/2);
}
public double avg(double a,double b){
return (a+b)/2;
}
构造函数重载
例如:
public News() {
}
public News(int id, String title,) {
super();
this.id = id;
this.title = title;
}
一般方法与属性分为两个类