class person
{
public int man;
public int women;
public long name;
public float weight;
public person()
{
this.name=name;
this.weight=weight;
}
}
class man extends person
{
public int work;
public int name;
public man(long name,float weight,int work)
{
super(name,weight);
this.work=work;
}
public void draw()
{
System.out.println("man:"+this.name+"\n"+"weight:"+this.weight+"\n"+"work:"+this.work);
}
}
class test2
{
public static void main(String args[])
{
man m=new man(茂军,175.5,doctor);
m.draw();
}
}
问题:在super(name,weight)处报“找不到符号”
问题:main函数是干什么作用的?
你小子骗分数阿,把我的代码复制了一遍,混
java上机题
答案:2 悬赏:70
解决时间 2021-02-19 02:26
- 提问者网友:心裂
- 2021-02-18 06:49
最佳答案
- 二级知识专家网友:懂得ㄋ、沉默
- 2021-02-18 07:17
你这个错误不只一处
首先name变量你传的是字符串所以应该是String型的.其次你的第二个参数传的是小数.应该用double型的,float型的会报错.而且man m=new man(茂军,175.5,doctor); 里的 茂军 应该有"".而且这个参数doctor你还没有定义.
其次你的person类的构造方法写错了.这个构造方法应该有2个参数.改成
public person(String name,double weight)
{
this.name=name;
this.weight=weight;
}
....改得太多了.我把改好的发下面
class person
{
public int man;
public int women;
public String name;
public double weight;
public person(String name,double weight)
{
this.name=name;
this.weight=weight;
}
}
class man extends person
{
public int work;
public int name;
public man(String name,double weight,int work)
{
super(name,weight);
this.work=work;
}
public void draw()
{
System.out.println("man:"+this.name+"\n"+"weight:"+this.weight+"\n"+"work:"+this.work);
}
}
class test2
{
public static void main(String args[])
{
int doctor=1;
man m=new man("",175.5,doctor);
m.draw();
}
}
至于问题2,main方法是一个程序的入口.而且一个程序有且只有一个入口.每个程序必须有一个main方法才能运行.....
这个申请追加分数....太费劲了
首先name变量你传的是字符串所以应该是String型的.其次你的第二个参数传的是小数.应该用double型的,float型的会报错.而且man m=new man(茂军,175.5,doctor); 里的 茂军 应该有"".而且这个参数doctor你还没有定义.
其次你的person类的构造方法写错了.这个构造方法应该有2个参数.改成
public person(String name,double weight)
{
this.name=name;
this.weight=weight;
}
....改得太多了.我把改好的发下面
class person
{
public int man;
public int women;
public String name;
public double weight;
public person(String name,double weight)
{
this.name=name;
this.weight=weight;
}
}
class man extends person
{
public int work;
public int name;
public man(String name,double weight,int work)
{
super(name,weight);
this.work=work;
}
public void draw()
{
System.out.println("man:"+this.name+"\n"+"weight:"+this.weight+"\n"+"work:"+this.work);
}
}
class test2
{
public static void main(String args[])
{
int doctor=1;
man m=new man("",175.5,doctor);
m.draw();
}
}
至于问题2,main方法是一个程序的入口.而且一个程序有且只有一个入口.每个程序必须有一个main方法才能运行.....
这个申请追加分数....太费劲了
全部回答
- 1楼网友:为你轻狂半世殇
- 2021-02-18 08:38
import java.io.*;
public class java_3{
public static void main(string[] args){
string sizestr;
string filename;
if(args.length > 1)
sizestr = args[1];
else
sizestr = "3000";
if(args.length > 0)
filename = args[0];
else
filename = "newfile.doc";
long size = 0;
try{
size = long.parselong(sizestr);
}
catch(numberformatexception e){}
try{
//*********found********
randomaccessfile raf = new randomaccessfile(filename,"rw");
//*********found********
raf.setlength(size);
raf.close();
}
catch(ioexception e){}
}
}
我要举报
如以上问答内容为低俗、色情、不良、暴力、侵权、涉及违法等信息,可以点下面链接进行举报!
大家都在看
推荐资讯