![]() |
![]() |
![]() |
If Java doesn't have pointers... how come it has a NullPointerException?
Just curious
Pass.
TheGeezer
"What I want to know is, does it really matter?"
Marvin
just cause you can't manipulate them doesn't mean they ain't there.
Captain Obvious
it's just semantics
When people say "Java doesn't have pointers", they mean these pointers:
Koz
Which is a bit of a b*stard in some ways. If you want to pass an array of "somethings" to a function you also need to pass an offset. In C you could just use a pointer to the place in the array where it starts and Bob's your uncle (again; he gets around a bit does your uncle).
Well, I just pass around java.util.List's. Haven't used an Array in ages. But whatever floats your boat ;)
Koz
Pass an offset vs a Pointer? What's the difference? You're passing one extra parameter either way.
name withheld out of cowardice
He meant that instead of calling
bigoted against java
Because Java does have 'references', which are a type-safe way of doing what pointers do for C. In C, when you throw around pointers, you are actually throwing around actual addresses to variables stored in memory space. A 'null' pointer actually points to the real location zero in your memory space. Trying to access that location usually results in a memory permission violation error.
AllanL5
From one point of view, all references are really "pointers" behind the scenes.
Avrom Finkelstein
Two words: Leaky Abstraction.
Almost Anonymous
That's NOT a leaky abstraction.
muppet
Sure it is... it's an implementation detail (oh, references are implemented as pointers?! gosh!) that's peaking through.
Almost Anonymous
That's a pretty generous definition of "leaky".
muppet
Sure.. but it's also pretty stupid to have a null pointer exception when the entire language specification makes absolutely no mention of the word "pointer".
Almost Anonymous
Shall we discuss the stupidities in PHP? :)
muppet
'the entire language specification makes absolutely no mention of the word "pointer"'
as
Hehe.. so they say "...special null reference..." but the exception is still null pointer.
Almost Anonymous
"Shall we discuss the stupidities in PHP? "
Just me (Sir to you)
In all fairness, I believe the original 'idea' of a 'pointer' came from Pascal. It was C that turned the 'idea' into an implementation where a 'pointer' became a literal address on the machine -- and then made the only way you could change the value of a parameter in a subroutine was to pass the subroutine a pointer to the parameter.
AllanL5
http://c2.com/cgi/wiki?NullPointerException
Avrom Finkelstein
The first pointers I saw were in assembler.
crotchety
|