b is not a static variable while a is thats why you are getting that error
Try decalring b in main and see the differnce
Yes vishal I understand that , if declared in main it will behave as a local variable , but
I just wanted to understand
why we cant assign the nonstatic variable a static value , rather than remembering it .
I assume its just a part of java , maybe there is no logic.