- public class Test {
- private String Book;
- private int Hao;
- public Test(){
- Book="书1";
- Hao =1;
- System.out.println("测试");
- }
- public Test(String b){
- Book = b;
- }
- public void setBook(String b){
- Book =b ;
- }
- publicTest(String b,int h){
- Book = b ;
- Hao = h;
- }
- public void aaa(){
- System.out.println(Book+","+Hao);
- }
- public static void main(String[] args){
- Test t=new Test();
- t.aaa();
- Test t1 =newTest("这是第一本书");
- t1.setBook("这是第二本书");
- t1.aaa();
- Test t2 =newTest("这是第三本书",3);
- t2.aaa();
- }
- }
来源: