标题:static问题
取消只看楼主
初心者1号
Rank: 1
等 级:新手上路
帖 子:42
专家分:0
注 册:2007-3-31
 问题点数:0 回复次数:0 
static问题

abstract class abc{
int num;
int num1;
String name;

abc(){
}

abc(int n1,int n2,String name1){
num=n1;
num1=n2;
name=name1;
}

int sj(){
return num*num1;
}

abstract void sj2();
}

class a extends abc{
static int sum=0;

a(int n1,int n2,String name1){
super(n1,n2,name1);
}

void sj2(){
sum= num+num1;
}

public static void main(String []w)
{
a t=new a(2,9,"li");
System.out.println(t.sj());
System.out.println(sum);
// System.out.println(t.sj2());
}
}

打印SUM总是0,不知道为什么。

搜索更多相关主题的帖子: static 
2007-05-26 07:56



参与讨论请移步原网站贴子:https://bbs.bccn.net/thread-142664-1-1.html




关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 1.610942 second(s), 8 queries.
Copyright©2004-2025, BCCN.NET, All Rights Reserved