[1671] in java-interest
Re: pointer in java
daemon@ATHENA.MIT.EDU (prepapol@lifl.fr)
Wed Sep 13 17:45:35 1995
From: prepapol@lifl.fr
Date: Wed, 13 Sep 95 20:51:52 +0200
To: java-interest@java.Eng.Sun.COM, lliang@bellcore.com
Larry Liang wrote :
|-I am new in java and could not find any information on the following
|-basic question.
|-
|-Since there is no pointer in java, how do I create a linked list of a
|-tree. The handle is more like a reference in C++ which does not seem
|-to be able to change the object it's referring to.
|-
If you want to use a linked list, you can use `Vector' in the java.util package.
class Node {
// contents of the node
Node Right;
Node Left;
// your methods
}
Seems to me ok for a binary tree...
class Node {
// contents of the node
Vector ListOfNodes;
// your methods
}
Seems to me ok for a n-aire tree...
|-One other question/comment, java requires the explicit creation of
|-object and strings, but not for other basic type such as int and
|-float. This appears to me to be a inconsistency and make the code not
|-as elegant. Is there a rationale behind this?
|-
When you instantiate an object from a class you must allocate it before using it:
String str= new String("Hello"); (or String str= "Hello")
But for int, byte, char,... you instantiate a variable and you haven't need to
initialise it.
For more information, You can find all the documentation at http://java.sun.com/
-------------------------------------------------
Bruno CUVELIER e-mail: prepapol@lifl.fr
Universite des Sciences et Technologies de Lille
Laboratoire d'Informatique Fondemmentale de Lille
Cite Scientifique
U.F.R. d'IEEA, batiment M3
59655 Villeneuve d'Ascq CEDEX.
FRANCE
-------------------------------------------------
-
Note to Sun employees: this is an EXTERNAL mailing list!
Info: send 'help' to java-interest-request@java.sun.com