Results 1 to 2 of 2
Thread: What is best object to create?
- 02-23-2011, 09:34 PM #1
Member
- Join Date
- Feb 2011
- Posts
- 2
- Rep Power
- 0
What is best object to create?
Hi,
Basically, I have a matrix that has been created using a double array. For each block of the matrix, I need to store four numbers. I cannot determine what kind of object/data structure I need to use in which to store these numbers. I know that I can create an object, and I would love to be able to say something like "firstvalue = matrix[i][j].firstvalue" in my driver program, but how would I go about storing firstvalue in my matrix object, especially since that currently is the name of my array?
Thanks,
lam5442
- 02-23-2011, 09:44 PM #2
Senior Member
- Join Date
- Feb 2010
- Location
- Waterford, Ireland
- Posts
- 748
- Rep Power
- 4
Reads like you need a class that will hold four double values and then store an instance of this class in each block of the array/matrix. Remember to set accessor and set methods in your class so you can retrieve the four values e.g. of one of the methods
Array storing and retrieving - (presume myClass is an instance of that class that holds 4 doubles say call it DoubleClass) and myMatrix is a 2d array of type DoubleClass (can hold objects of DoubleClass)Java Code:public double getX(){ return x; // where x is a member of class }
Java Code:myMatrix[i][j]=myClass; // assign double value=myMatrix[i][j].getX(); // retrieve doubles
Similar Threads
-
Create new Calendar object???
By aliencc in forum New To JavaReplies: 4Last Post: 01-17-2011, 01:19 PM -
Create object of unknown class, based on existing object
By Zack in forum New To JavaReplies: 2Last Post: 06-22-2010, 04:29 AM -
create object
By paul21 in forum New To JavaReplies: 4Last Post: 03-07-2010, 07:14 PM -
create object with name from string
By skandalouz in forum New To JavaReplies: 7Last Post: 12-05-2009, 11:40 PM -
how to create an object at runtime
By sireesha in forum New To JavaReplies: 8Last Post: 10-01-2008, 12:52 PM


LinkBack URL
About LinkBacks
Reply With Quote
Bookmarks