Shop OBEX P1 Docs P2 Docs Learn Events
null pointer on String — Parallax Forums

null pointer on String

Don FrenchDon French Posts: 126
edited 2007-03-18 14:25 in General Discussion
I get an NPE in the String class. Not sure what causes this or how to fix it. It kind of looks like a Javelin bug. One other question, when trying to debug the code, it tells me that there are no line numbers in one of my classes. Is there a switch I have to set to get line numbers, or what?

Comments

  • Don FrenchDon French Posts: 126
    edited 2007-03-16 02:18
    Well, I fixed it but I don't understand yet. The unhandled NPE occurred in the construction of an object of a class of mine. I had code like this:


    public class ClassA {

    static ClassB rf = new ClassB(1, 2);

    public static void main(){
    return;
    }

    and I changed it to code like this:
    public class ClassA {

    static ClassB rf;

    public static void main(){
    rf = new ClassB(1, 2);
    return;
    }

    and the NPE went away. Why is this?
  • Don FrenchDon French Posts: 126
    edited 2007-03-16 02:22
    I was also wondering why String NPEs are not handled. It would be very useful if the exception handler printed a stack trace, for example. Not possible?
  • Peter VerkaikPeter Verkaik Posts: 3,956
    edited 2007-03-16 02:45
    I think the error originates in classB.
    Moving the creation of a new classB into main() made the
    error disappear because main() only gets to run after
    the initialization of all used classes is done.
    Without seeing the actual classes used, that is my best guess.
    If you use debug instead of just program, you can single step
    your code and it will show a call/stack trace.

    regards peter
  • JossJoss Posts: 32
    edited 2007-03-18 14:25
    What does ClassB look like?

    Regards
Sign In or Register to comment.