关键字
this
package com.itcode.demo;
/**
* @author: 成都码到功成学员
* @Description: this关键字
*
*/
public class TestThis {
int a;
int b;
int c;
//无参构造
public TestThis(){
}
//有参参构造
public TestThis(int a, int b){
// TestThis()//无法这样用。
System.out.println(a+b);
}
public TestThis(int a, int b, int c){
this(a, b);// 调用有参/无参。//构造方法中用,必须位于构造方法的第一句。
this.c = c;
}
public void study() {
System.out.println("成都码到功成学习");
}
void eat() {
this.study();// 调用本类方法
System.out.println("睡觉");
}
public static void main(String[] args) {
// TODO Auto-generated method stub
// System.out.println(this);// this不能用于static方法中
new TestThis().eat();
}
}
static

代码块

参数传递

package
Eclipse项目中使用package

Java常用package介绍
import
Last updated