hi
why this pgm is getting NUllPointer.
Code:public class Split {
static Integer intobj;
static void print(int val){
int x=10;
System.out.printf("%d", x+val);
}
public static void main(String[] args) {
print(intobj);
}
}
Printable View
hi
why this pgm is getting NUllPointer.
Code:public class Split {
static Integer intobj;
static void print(int val){
int x=10;
System.out.printf("%d", x+val);
}
public static void main(String[] args) {
print(intobj);
}
}
You need to initialize intobj.
use:
static Integer intobj = new Integer(10);
Or, declare intobj as an int.
The difference being Integer is an object whilst int is a primative data type.
Regards.