I have a class which I am using for data stroage. I declare an
instance of that class in my main class which is running my java
applet. I Iassign it a value in the init () function and it works
fine but when I try to do the same assignment later on, it restults in
a NullPointerException and I can not figure this out. Could someone
please help. Thanks.
Here's the code:
public class A extends java.applet.Applet
{
TData tinfo [];
public void init()
{
//This will print out fine with no exception
tinfo = new TData[3];
tinfo [0] = new TData();
tinfo [1] = new TData();
tinfo [2] = new TData();
tinfo [0].localt = "BS";
System.out.println (tinfo[0].localt);
}
public void processdata ()
{
//gets the string the user has entered
String str = userinf.getText ();
//results in the exception
try {
tinfo[0].local_ticker = "BS";
}
catch (Exception e){ System.out.println ("SET" + e);}
}
}
//TData class from another file:
public class TData
{
String localt;
//added an initalizeation method but did nothing .. shouldn't need
one since this modifying a String
}
Any Suggestions ???