Hai every1,
we all know that java does not support pointers.Then how does it throw null pointer exception ?????
Hai every1,
we all know that java does not support pointers.Then how does it throw null pointer exception ?????
yes JAVA does not support pointers but internal implementation of JVM or JAVA compiler uses pointers, as u know JVM consists of stack and heap, stack contains the normal variables and objects r kept in heap and those heap address are stored in stack those addresses r nothing but pointers to those objects in heap so when u write ur programs using java u yourself don't use pointers but compiler does for convenience
This is not true. Java does in fact support pointers. When you allocate memory for an object by calling new, you get back a pointer.
What you should say is, "We all know that Java does not support pointer arithmetic." The Java language does not allow you to add offsets to a pointer, as is often done in C or C++. People sometimes get confused about this and think that Java does not support pointers at all.
hi,
Who told you that java doesn't support pointers. Without pointers no programming language can allocate memory. So internally java also make use of pointers. But only thing is that, java doesn't allow you to get explicit control over Pointers. And it doesn't support pointer arithmetic. That is the most important thing.
Java also needs memory to be allocated to objects, you will have to explicitly do that with 'new' operator. Thats why you are getting NullPointerException when you try to access a method of an object without instantiating the object. ptmidhun@gmail.com
well what i think is it should have been called NULLREFERENCEEXCEPTION instead of null pointer..
whether Java supports or does not support can be answerd just by answered " Can u use pointers in your program?"
Java dont support pointer.
Here NullPointerException means that it can't map any null object.
Ex1: JButton but1
but1.setSize(10,15) // There will be an NullPointerException because, without initializing it we can't use it.
Now tht fress code::
JButton but
but=new JButton("Click")
but.setSize(15,15) // There wil no exeption
for more details call me @ :9333344452 (Susanta Ghosh)
or mail me at amarmail . 999 @ gmail . com