Why jvm doesn't allow me to do calc between a static and a non static variable. | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
0

Why jvm doesn't allow me to do calc between a static and a non static variable.

like this static int i=0; int a; a=++i; error occurs when executed. what is the problem because of which jvm doesn't allow me to do this.

25th Mar 2017, 7:42 PM
pranjal kumar
pranjal kumar - avatar
1 Answer
+ 13
Same reason as here: https://www.sololearn.com/Discuss/276965/?ref=app You don't need static in your example. Leave it out.
26th Mar 2017, 4:10 PM
Tashi N
Tashi N - avatar