On Jun 16, 9:10 pm, RFlem...@NationalSteel.com wrote:
> Hello,
>
[quoted text clipped - 3 lines]
> example: Socket[] socketarray = null; socketarray[1]
> ("127.0.0.1","8000");
Socket[] socketArray = new Socket[13];
socketArray[1]= new Socket("127.0.0.1","8000");
but I would use a LinkedList or Vector or something -- arrays are not
particularly useful.
> If so I also can not seem to figure out how to do..... Socket
> tempsocket = socketarray[1];
[quoted text clipped - 5 lines]
>
> Ryan
Lew - 17 Jun 2007 15:18 GMT
> On Jun 16, 9:10 pm, RFlem...@NationalSteel.com wrote:
>> Hello,
[quoted text clipped - 14 lines]
>> I have not seen any examples of arrays that appear to use Class
>> objects such as the Socket, just using primitive types such as ints,
A Socket is not a Class object. An instance of Socket is a Socket object.
Class is a different class from Socket.
>> bools, etc..... Any help would be greatly appreciated!
Arrays of reference types are extremely common. Every basic tutorial includes
at least a mention of them. For example, the basic Sun tutorial
<http://java.sun.com/docs/books/tutorial/java/nutsandbolts/arrays.html>
mentions
String[] anArrayOfStrings;
and
String[][] names = {{"Mr. ", "Mrs. ", "Ms. "},
{"Smith", "Jones"}};
However, they do not seem to go into the details of how to new and array. One
can always go to the JLS for the final word:
<http://java.sun.com/docs/books/jls/third_edition/html/arrays.html>
in particular
<http://java.sun.com/docs/books/jls/third_edition/html/arrays.html#10.3>
which links to
<http://java.sun.com/docs/books/jls/third_edition/html/expressions.html#15.10>
which shows you that the syntax for array creation is precisely the same for
primitives as it is for reference types.
Isn't the JLS useful?
So having the knowledge of how to create an array of primitives confers
automatically the knowledge of how to create an array of references. Simply
use the 'ClassOrInterfaceType' in lieu of the 'PrimitiveType'.

Signature
Lew