title: What is way to check weather object of class is assigned an instance of class or not in Java?
body: <p>I've put just small snippet of large code to explain my question:</p>
  
  <pre><code>class A 
  {
      B b= new B();
      B z; 
      void xyz(){
          if(// condition to check z is not assigned instance of class B){
          z=b;
          }
          else{
          z= new B();
          }
      }
  }
  
  class B{
  //variables and methods
  }
  </code></pre>
  
  <p>I want an Expression in if block of xyz() to check weather object z have assigned an instance of B or not where I've made comment in if block's bracket.
  or in other way. </p>
  
  <p>what is a way to check weather any java object have instance of their class or not?</p>