永发信息网

请写一个java程序,其中包含实例变量,类变量和常量?

答案:2  悬赏:10  手机版
解决时间 2021-12-25 15:29
  • 提问者网友:难遇难求
  • 2021-12-24 20:58
请写一个java程序,其中包含实例变量,类变量和常量?
最佳答案
  • 五星知识达人网友:佘樂
  • 2021-12-24 21:11
实例变量,类变量和常量都包含:
你试试吧
public class Task{
int i=0;
public static void main(String[] args){
subTask su=new subTask();
System.out.println ("subTask.intSubName= "+ su.intSubName);
System.out.println("subTask.fPi= "+ su.fPi);

Task t=new Task();
t.i=5;
System.out.println("t.i "+ t.i);

}
}
class subTask{
String intSubName="subTask";
double fPi=3.14;
}
全部回答
  • 1楼网友:零点过十分
  • 2021-12-24 22:24
public class student{ string number; string name; string sex; boolean isleader; float math; float yuwen; public student(string number,string name,string sex, boolean isleader, float math,float yuwen){ this.number=number; this..... .... } }
我要举报
如以上回答内容为低俗、色情、不良、暴力、侵权、涉及违法等信息,可以点下面链接进行举报!
点此我要举报以上问答信息
大家都在看
推荐资讯