how do you printin the sum of variables | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 1

how do you printin the sum of variables

16th Jul 2017, 8:51 AM
Nahom
4 Answers
+ 4
use print function and add them either inside the function or out. System.out.println (a+b);
16th Jul 2017, 8:56 AM
Farshad
Farshad - avatar
+ 2
System.out.println(x+y); where x and y are your variables
16th Jul 2017, 9:03 AM
Rishan 11
Rishan 11 - avatar
+ 1
Make sure that the two variables you want to add are Integers. if not use: Integer.parseInt(strVar) If both variables are Integers then do System.out.println(a+b)
16th Jul 2017, 9:05 AM
Limitless
Limitless - avatar
0
int x = 5; int y = 10; System.out.println(x + y); /*or*/ int x,y,z; x = 5; y=4; z=6; System.put.println(x + y + z);
16th Jul 2017, 12:39 PM
D_Stark
D_Stark - avatar