title: How do I access the methods and Global variables of outer class from an inner class object, and if I cannot what is purpose of having an Inner class
body: <pre><code>public class StaticAndInnerClasses {
      String testString;
      class InnerClass{
      int x;
      int y;
  
  
      }
      static class InnerStaticClass{
      int a=10;
      int b=20;
  
      }
      public void changeCharacter(){
      testString="Characters modified";
      }
      public static void main(String[] args){
      StaticAndInnerClasses.InnerStaticClass statciClassObject=new StaticAndInnerClasses.InnerStaticClass();
      StaticAndInnerClasses outerObject=new StaticAndInnerClasses();
      outerObject.changeCharacter();
      InnerClass innerClassObject=outerObject.new InnerClass();    
      innerClassObject.changeCharacter();   
  
  
  
    }
      }
  </code></pre>
  
  <p>As you can see in my code that I have created a innerClassObject in the last line, now I want to know why I am not able to access the String testString using innerClassObject. isn't testString a Global variable and haven't I created the instance of innerClass within the outerClass .i.e "StaticAndInnerClasses" And if it is not possible then why have the Inner  Classes</p>