question about JAVA(how to increment a result?) | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
0

question about JAVA(how to increment a result?)

for example int a = 1165; System.out.println(Math.sqrt(a)); the answer is 34 from console,then i wanna increment this reasult or work on this result directly, without bringing another variable and giving a value of the result like this [ int b=34; System.out.println(++b); ]

12th Feb 2021, 7:30 PM
Arena Army
Arena Army - avatar
2 Answers
+ 2
You can assign the result back to the same variable. int a = 1165; a = (int)Math.sqrt(a); System.out.print(++a);
12th Feb 2021, 7:40 PM
Avinesh
Avinesh - avatar
0
Thanks ! it works
12th Feb 2021, 7:55 PM
Arena Army
Arena Army - avatar