Mailing Lists: Apple Mailing Lists

Image of Mac OS face in stamp
 
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: looking at generic



At 12:04 pm -0700 30/10/04, Elliotte Harold <email@hidden> wrote:

 You still *think* C++, apparently. How can "dereference a null pointer " in
 Java ?

String s = null; int c = s.charAt(0);

Normally it's more subtle than that, of course.

S is not a pointer. It's a reference.

No, s is a pointer, not a reference (in the C++ sense; in Java terminology there's no difference and they're synonymous).


When people say "Java is just C++ but everything is reference and there are no pointers" what they actually mean is "Java is just like C++ but everything is a pointer, there are no references (only Java uses a different syntax from C++)".

Java takes the syntax that C++ uses for reference but uses it for pointers. Java "a.b" is C++ "a->b", Java "a[5]" is C++ "a+5". In that case, you might ask, how do you write C++ "*ptr" or "ref.a" or "a[5]" in Java? Answer, you don't, they're meaningless because Java doesn't have references!

-Rolf
--
Rolf Howarth, Square Box Systems Ltd, Stratford-upon-Avon UK.
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Java-dev mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/java-dev/email@hidden

This email sent to email@hidden


Visit the Apple Store online or at retail locations.
1-800-MY-APPLE

Contact Apple | Terms of Use | Privacy Policy

Copyright © 2007 Apple Inc. All rights reserved.