someClass myobject=new someClass("test");
List <someClass> mylist;
mylist.add(myobject);
Ok, the first error I got is mylist is initialized, so I did List myList=NULL;
then it has a warning saying accessing NULL pointer at mylist.add(myobject). variable mylist can only be NUll at this point.
List <someClass> mylist=NULL;
So, when I runs the program, the system crashed. But if don’t set to NULL, compiler also have an error saying it’s not initialized.
You need to initialize it to a reference to a new list. For example:
Note that this sort of question suggests you’re very new to Java. I would strongly recommend that you start off learning Java as a language via plain desktop Java – console apps and the like. That will let you learn without worrying about additional difficulties of mobile development, emulators, trying to handle user interfaces, etc. All of these things will need to be learned about in time, of course, but learning the basics in a somewhat simpler environment is helpful.