Saturday, 1 October 2011

Constructor Addition

/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package addition;

/**
 *
 * @author Zeeshan
 */
class add1
{

float n3;
int n1;
int n2;

public void add1(int num1, int num2)
{
n1=num1;
n2=num2;
System.out.println("addition 1 is :"+(n1+n2));
}

public void add1(int num1, int num2,float f1)
{
n1=num1;
n2=num2;
n3=f1;
System.out.println("addition 2 is :"+(n1+n2+n3));
}

public void add1(float f1, int num2, int num1)
{
n1=num2;
n2=num1;
n3=f1;
System.out.println("addition 3 is :"+(n1+n2+n3));
}


public static void main(String[] args)
{
add1 ad1=new add1();
ad1.add1(5,5);
ad1.add1(2,5,5.5f);
ad1.add1(2.5f,4,5);
}
}

No comments:

Post a Comment