title: using inner class object in outer class java
body: <p>I am facing a problem converting json object to POJO class.</p>
  
  <p>I have a public class called Service and it has an inner class User. I want to use the inner class as a container/object to hold the variables for all my outer class methods. I am trying to do the below, but I am getting compilation errors. Please show how I can do this and please correct the mistake I am doing in my code below.  </p>
  
  <p>From eclipse debug window, i see the below json being obtained in node variable
  node : {"firstName":"ndndbs","lastName":"dnjdnjs"}</p>
  
  <p>Trial 1:      </p>
  
  <pre><code>public class Service {
                               // Method
  public boolean createUserAccount(JsonNode node) throws Exception {
          ObjectMapper mapper = new ObjectMapper();
           User user=null;
          try {
              Service service=new Service();
              user = mapper.readValue(node, User.class);    
          } catch (Exception e) {throw new Exception("failed to bind json", e);}
  
       System.out.println("Use this anywhere in method"+userNode.firstName); 
      }
  
  }
                                 // Inner class
  public class User {
          public String firstName;
          public String lastName;
      }
          }
  
  OUTPUT:
  NULL POINTER EXCEPTION AND user=null even after execution of mapper.readValue() statement
  </code></pre>