This week's book giveaway is in the General Computing forum.
We're giving away four copies of Arduino in Action and have Martin Evans, Joshua Noble, and Jordan Hochenbaum on-line!
See this thread for details.
The moose likes Beginning Java and the fly likes Help with constructor Big Moose Saloon
  Search | Java FAQ | Recent Topics
Register / Login


JavaRanch » Java Forums » Java » Beginning Java
Reply Bookmark "Help with constructor" Watch "Help with constructor" New topic
Author

Help with constructor

Taheerah Nasai
Greenhorn

Joined: Apr 18, 2005
Posts: 1
If I have a
constructor: public Persons(Person[] aList, int aSize) & a
field: private Person[] personList;

how can I 1. Form a Person array of length aSize and put the address of this array into personList. 2. Then use the constructor to copy the first aSize persons from aList onto the newly created array.
Michael Dunn
Ranch Hand

Joined: Jun 09, 2003
Posts: 4632
see if you can follow along with this
(I scrapped 'aSize' in the constructor)

David Harkness
Ranch Hand

Joined: Aug 07, 2003
Posts: 1646
You can create an array using the new operator, just like classes:This creates an array of twelve ints, each initialized to the default value zero. You can use System.arraycopy() to copy a range of values from one array to another.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Help with constructor
 
Similar Threads
Calling "ToArray" From List
Adding to ArrayList in a Constructor
Arrays.asLIit() casting exception (JDK 1.4)
Sorting TreeSet using Comparator
Problem in hibernate join result