我有同一个类的不同构造函数,我想用同一个对象调用它们。可能吗?
如:
class Calcy
{
int a,b,d;
double c;
Calcy()
{
c=a+b;
System.out.println("Ans -> "+c);
}
Calcy(int a,int b)
{
c=a/b;
d=a%b;
System.out.println("Ans -> "+c+d);
}
Calcy(double a,double b)
{
c=a*b;
System.out.println("Ans -> "+c);
}
public static void main(String[] args)
{
Calcy **cal** = new Calcy(7,6);
Calcy **cal** = new Calcy(5.3,6.1);
Calcy **cal** = new Calcy();
}
}