Exception in thread "main"
以下是代码:
class Complex
{
// a为实部,b为虚部
private double a;
private double b;
public Complex()
{
}
public Complex(double a, double b)
{
this.a = a;
this.b = b;
}
// 设置相关属性
public void setA(double a)
{
this.a = a;
}
public void setB(double b)
{
this.b = b;
}
// 得到相关属性
public double getA()
{
return a;
}
public double getB()
{
return b;
}
// 重写Object类的toString()方法
public String toString()
{
return "(" + a + " + " + b + "i)";
}
}
public class ComplexTest
{
private static Complex c;
public static Complex add(Complex c1, Complex c2)
{
c = null;
c.setA(c1.getA() + c2.getA());
c.setB(c1.getB() + c2.getB());
return c;
}
public static Complex subtract(Complex c1, Complex c2)
{
c = null;
c.setA(c1.getA() - c2.getA());
c.setB(c1.getB() - c2.getB());
return c;
}
public static Complex multiply(Complex c1, Complex c2)
{
c = null;
c.setA(c1.getA() * c2.getA() - c1.getB() * c2.getB());
c.setB(c1.getB() * c2.getA() + c1.getA() * c2.getB());
return c;
}
public static Complex divide(Complex c1, Complex c2)
{
c = null;
c.setA((c1.getA() * c2.getA() + c1.getB() * c2.getB()) /
(c2.getA() * c2.getA() + c2.getB() * c2.getB()));
c.setB((c1.getB() * c2.getA() - c1.getA() * c2.getB()) /
(c2.getA() * c2.getA() + c2.getB() * c2.getB()));
return c;
}
public static void main(String args[])
{
Complex c1 = new Complex(1, 2);
Complex c2 = new Complex(3, 4);
System.out.println(add(c1, c2));
System.out.println(subtract(c1, c2));
System.out.println(multiply(c1, c2));
System.out.println(divide(c1, c2));
}
}
相关推荐
Exception in thread main java.lang.UnsatisfiedLinkError解决.doc
Exception in thread main java.lang.UnsatisfiedLinkError解决
Exception in thread "main" java.lang.NoClassDefFoundError: org/json/JSONObject,是因为缺少java-json.jar-附件资源
Exception in thread "main" java.lang.NoClassDefFoundError: org/json/JSONObject,是因为缺少java-json.jar-附件资源
Exception in thread main java.lang.NoClassDefFoundError错误解决方法
主要介绍了Exception in thread main java.lang.NoClassDefFoundError错误解决方法,需要的朋友可以参考下
Exception in thread "main" java.lang.NullPointerException
希望高手指点
2760张伤口图像VOC+YOLO双格式数据集实战指南
目标检测是计算机视觉的基础任务,其核心依赖高质量、格式合规的标注数据。VOC和YOLO作为两大主流标注格式,分别承载结构化语义表达与工程化训练效率:VOC XML支持可视化校验、临床可读性与合规审计,YOLO txt则保障高速加载、框架兼容与边缘部署轻量性。在医疗AI场景中,伤口检测面临小目标、低对比、纹理弱等挑战,对数据一致性、坐标归一化、类别索引(如单类wound的class_id=0)和图像尺寸匹配提出严苛要求。本文围绕2760张真实临床伤口图像,详解VOC与YOLO双格式协同构建、自动化校验(val


Eclipse
