Chinaunix首页 | 论坛 | 博客
  • 博客访问: 696745
  • 博文数量: 160
  • 博客积分: 8847
  • 博客等级: 中将
  • 技术积分: 1656
  • 用 户 组: 普通用户
  • 注册时间: 2010-11-25 16:46
个人简介

。。。。。。。。。。。。。。。。。。。。。。

文章分类

全部博文(160)

文章存档

2015年(1)

2013年(1)

2012年(4)

2011年(26)

2010年(14)

2009年(36)

2008年(38)

2007年(39)

2006年(1)

分类: Java

2008-10-30 17:32:27


看看下面的java代码输出值是多少?
答案:(选中下面即可看到   
10d
TestThis@190d11




public class TestThis {
    //TestThis的成员变量

    int _i = 0;
    private String name;
    private int age;
    private String password;
   
    //构造函数1

    TestThis (int i){
        //this表示当前对象(TestThis这个类)的引用

        this._i = i;
    }
   
    //构造函数2

    TestThis (String name,int age,String password){
        //在构造函数中,通过this调用另外一个构造函数。这种调用,必须写在方法的第一句。

        this(age);
        this.name = name;
        this.age = age;
        this.password = password;
        System.out.println(this.age + this.age + this.password);
    }
   
    //返回当前实例的引用

    TestThis f(){
        return this;
    }
   
    TestThis increament(int i){
        i++;
        return this.increament(5).increament(6);
    }
   
    String Print(){
        System.out.print(this._i);
        return "dd";
    }

    public static void main(String[] args) {
        // TODO Auto-generated method stub

        TestThis tt = new TestThis("d" ,5 , "d" );
        System.out.println(tt.f());
    }
}

阅读(919) | 评论(0) | 转发(0) |
0

上一篇:static关键字

下一篇:Oracle 学习笔记

给主人留下些什么吧!~~