ITeye博客

Double的Complex()的方法

keating · 2008-11-05 11:15 · Java · Markdown

class Complex{

   //instance variables

double real,imag;

public static void main(String args){ Complex a=new Complex(1.0,1.1); Complex b=new Complex(1.0,1.1); boolean c=a.equals(b); System.out.println(c); }

//constructor public Complex(){ this.real=0.0;this.imag=0.0; }

//constructor public Complex(double real,double imag){ this.real=real;this.imag=imag; }

public boolean equals(Complex b){ if(b==null) return false; return (real==b.real && imag==b.imag); } }

评论(0)

暂无评论。

评论功能维护中,当前仅展示历史评论。