View Single Post
Old Jun 4th, 2006, 8:13 PM   #13
Eric the Red
Hobbyist Programmer
 
Eric the Red's Avatar
 
Join Date: Feb 2006
Posts: 214
Rep Power: 0 Eric the Red is an unknown quantity at this point
another error from code

Another problem in my code is that I'm not able to send array information between classes. I've created a sample program: Would anyone be able to fix this program so that it actually returns the array?

In c++, I would just send a pointers/refferencea to my array and into the class method. In java is there anyway I can have a pointer to my array in ArrayCollect, and bring that pointer into ArrayData. Or does this work with by fixing the syntax errors?

 Edit**
class ArrayData
{
    int someInt [] = new int [1];

    public ArrayData ()
    {
        someInt = new int [3];

        for (int i = 0 ; i < 3 ; i++)
        {
            someInt [i] = (5 * i) + 1;
        }
    }


    int getInt ()
    {
        return someInt [];
    }
}
class ArrayCollect
{
    public static void main (String [] arguments)
    {
        ArrayData tempData = new ArrayData ();
        int yeint[] = new int[3];
       yeint[] = tempData.getInt ();
  
    }
}
__________________
Death smiles at us all. All a man can do is smile back.
Eric the Red is offline   Reply With Quote