All the answers explained about &
and &&
very well.
But, after you edit your are still getting NullPointerException
then problem is your object
is null
on which you are calling getsomeFiles()
method.
list1=object.getsomeFiles();
↑ //null
In you code if you have
SomeFileClass object; //here object is null
Make sure that object
is initialized like:
object = new SomeFileClass();
Or initialize at object creation
SomeFileClass object = new SomeFileClass();
From Java docs NullPointerException
Thrown when an application attempts to use null
in a case where an object is required. These include:
- Calling the instance method of a null object.
- Accessing or modifying the field of a null object.
- Taking the length of null as if it were an array.
- Accessing or modifying the slots of null as if it were an array.
- Throwing null as if it were a
Throwable
value.