Link to home
Start Free TrialLog in
Avatar of Kyle Hamilton
Kyle HamiltonFlag for United States of America

asked on

modify variable of parent class

public class Parent{
   String regExpr;
   String target;
   public static ArrayList<Character> language;
   public Regex(String regExpr, String target){
		this.regExpr = regExpr;
		this.target = target;
		this.language = language;
	}
   private class Child{
     void buildLanguage(char c){
         language.add(c);
      }
   }
}

Open in new window


I would like to modify the language variable of the parent class, but I'm getting a java.lang.NullPointerException on the line: language.add(c);

Can this be done?
ASKER CERTIFIED SOLUTION
Avatar of Am P
Am P
Flag of India image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of Kyle Hamilton

ASKER

thanks for explaining.

I ended up redesigning the classes, so that the "Child" class is now it's own class, with a public  method that returns the language variable. this means my "Child" class is potentially re-usable in other projects.

cheers.