gpt4 book ai didi

java - 线程中的异常 "main"java.lang.NoclassDefFoundError : cal/class

转载 作者:行者123 更新时间:2023-12-01 19:22:58 25 4
gpt4 key购买 nike

enter import java.io.*;
class eval
{
double add(double a,double b)
{
return (a+b);
}
double sub(double a,double b)
{
return (a-b);
}
double mul(double a,double b)
{
return (a*b);
}
double div(double a,double b)
{
return (a/b);
}
}

class cal extends eval
{
public static void main(String args[])throws IOException
{
eval a1=new eval();
try{
System.out.println("1) Add");
System.out.println("2) Subtract");
System.out.println("3) Multiply");
System.out.println("4) Divide");
System.out.println("5) Enter your choice");
BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
int ch;ch=Integer.parseInt(br.readLine());
System.out.println("Enter two number");
double a;a=Integer.parseInt(br.readLine());
double b;b=Integer.parseInt(br.readLine());
switch(ch)
{
case 1:
a1.add(a,b);
break;
case 2:
a1.sub(a,b);
break;
case 3:
a1.mul(a,b);
break;
case 4:
a1.div(a,b);
break;
}
}
catch (IOException e)
{
System.out.println("Error occured, please restart application.");
}
}

}

最佳答案

您尝试像这样运行它:

java cal.class

您应该只指定类名而不是文件名称:

java cal

(我怀疑您可能对实际代码还有更多疑问,但请使用其他问题来解决这些问题。首先,cal 没有理由扩展 eval...您可能会考虑更有意义的名称。)

关于java - 线程中的异常 "main"java.lang.NoclassDefFoundError : cal/class,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/3034019/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com