Adding numbers in Java?

uzairadamjee / February 8, 2018

For adding numbers of same type we have to first define the variables. Like in below code we define two variables of type int. 

int i=5;  
int j=10;

int sum = i + j;



For adding numbers which have different types; int i=5; float j=10;

float sum = i + j;


Sum variable type should be in float (data type)


Leave a Reply

Your email address will not be published.