Results 1 to 6 of 6
Thread: help with and array of objects
- 01-22-2011, 08:51 PM #1
Member
- Join Date
- Oct 2010
- Posts
- 45
- Rep Power
- 0
-
- 01-22-2011, 09:30 PM #3
Member
- Join Date
- Oct 2010
- Posts
- 45
- Rep Power
- 0
ok sorry about that
here is a better example of the problem
i want to put Math.random() * 50 for the paramaters of each object in the array, is there just another way to do it without creating a 1000 different objects individuallyJava Code:Point [] coordinates = new Point[1000]; coordinates[0] = new Point (Math.random() * 50 , Math.random() * 50); coordinates[1] = new Point (Math.random() * 50 , Math.random() * 50);
- 01-22-2011, 09:53 PM #4
Senior Member
- Join Date
- Dec 2010
- Posts
- 100
- Rep Power
- 0
-
You will likely use a for loop to loop through the array inserting Points into each item of the array, but this will necessarily create 1000 Point objects. I don't really see any way around that. Are you concerned with the amount of memory that this will take -- if so, I wouldn't worry. Are you confused on how to set up this for loop? Again, your question needs more detail.
- 01-23-2011, 02:45 AM #6
Member
- Join Date
- Oct 2010
- Posts
- 45
- Rep Power
- 0
Similar Threads
-
Array of objects
By Saletra in forum New To JavaReplies: 2Last Post: 07-31-2010, 12:16 PM -
Array of Objects
By sfe23 in forum New To JavaReplies: 19Last Post: 02-04-2009, 05:57 PM -
Array of objects
By rosh72851 in forum New To JavaReplies: 5Last Post: 10-31-2008, 04:03 AM -
Array with objects
By toby in forum New To JavaReplies: 1Last Post: 07-25-2007, 09:50 AM -
array of objects
By Jack in forum New To JavaReplies: 2Last Post: 07-02-2007, 05:24 AM


LinkBack URL
About LinkBacks
Reply With Quote

Bookmarks