RSS
热门关键字:  java  Ajax  JSP  JSF  Struts
当前位置 : 首页>Java>列表

java第二课

来源: 作者: 时间:2007-08-24 点击:
{
Point.output();
}

}

编译运行:

如果我们试图在类方法(静态方法)中引用非静态的成员变量,将会出错: 

class Point{
int x,y;
Point(
int a,int b){
x
=a;
y
=b;
}

Point()
{
this(25,25);
}

static void output(){
System.out.println(
"output() called!");
System.out.println(x); 
//打印x
System.out.println(y); //打印y
}

public static void main(String[] args)
上一篇:Java第一课
下一篇:Java第三课
最新评论共有 0 位网友发表了评论
发表评论
评论内容:不能超过250字,需审核,请自觉遵守互联网相关政策法规。
用户名: 密码:
匿名?
注册
Google Adsense
相关文章