0

I thought that an uninitialized variables are set to null by default example shown below:

Public class foo{
Object bar;

    public void check(){
       while(bar != null){
          // Do something

        }
      }
    }

Inside the method I am getting an error about checking an uninitialized object. But by default Java would set this to null? Thanks

user3023003
  • 53
  • 1
  • 7

1 Answers1

0

Object bar should have been initialised to null. You might get a warning about using an uninitialised variable.

Gavin
  • 1,725
  • 21
  • 34