13.首先,编写一个类ChongZai,该类中有3个重载的方法void print();其次, 再编写一个主类来测试ChongZai类的功能。

package com.hanqi.test;

public class ChongZai {
void print()
{
System.out.println("无参数");
}
void print(double a)
{
System.out.println(a);
}
void print(String b)
{
System.out.println(b);
}

}

//主类
package com.hanqi.test;

public class TestChongzai {

public static void main(String[] args) {

ChongZai a=new ChongZai();
a.print();
a.print(5.5);
a.print(" adcd");

}

}

//结果
无参数
5.5
adcd

posted @ 2016-09-20 11:52  削肾客  阅读(1678)  评论(0)    收藏  举报