title: How to check a boolean method return value in java
body: <p>I am pretty new to Java what I am trying to do may seem really strange but it is a matter of me understanding a little bit about how Java works more than actually accomplishing a set result.</p>
  
  <p>If I have a boolean method for instance:</p>
  
  <pre><code>public class doThings
  {
  
      // imagine the intial value of this variable is set
      // and or modified using getters and setters between the declaration
      // and the following method
      private boolean boolVar;
  
  
      public boolean doSomething()
      {
          if(boolVar == true)
          {
              //does things and then returns true
              return true;
          }
          else
          {
              return false;
          }
      }
  }
  </code></pre>
  
  <p>And I want to call this method in another class like so...</p>
  
  <pre><code>public class testDoThings
  {
  
      doThings someObject = new doThings;
      public static void main(String[] args)
      { 
          someObject.doSomething()
      }
  } 
  </code></pre>
  
  <p>How do I check (in the class <code>testDoThings</code>) to see if the method has returned true or returned false and print messages accordingly something like this...</p>
  
  <pre><code>public class testDoThings
  {
  
      doThings someObject = new doThings;
      public static void main(String[] args)
      {
  
          someObject.doSomething()
          if (doSomething() returns true) // yes I am aware this is not
                                          //valid
          { 
              // print a statment
          }
          else if (doSomething() returns false) // yes once again not valid
          {
              // print a different statement           
          }
      }
  } 
  </code></pre>
  
  <p>I am aware that you could put these messages in the class containing the method but if I want different messages depending on where the method is called and what it is a called on then putting things in the original class method is not always going to work.</p>
  
  <p>If I am completely off the track here please let me know, if someone can explain this to me though, that would be great!</p>