• We’re currently investigating an issue related to the forum theme and styling that is impacting page layout and visual formatting. The problem has been identified, and we are actively working on a resolution. There is no impact to user data or functionality, this is strictly a front-end display issue. We’ll post an update once the fix has been deployed. Thanks for your patience while we get this sorted.

Array of Objects Problem

BarneyInTechno

Junior Member
hi, i gota stupid problem that i dont see why i have. This is the prob. i am passin in an array of objects through my main of a class Algorithm, and than it takes it in, sets the value to another array, than i use it later on, i do this by :

public Algorithm( Object [] x, int size, int max )
{
vertex = new Object[size];
for ( int i = 0; i < size; i++ ) // Moves over info from x to vertex
{
vertex = new Object();
vertex = x;
}
}

and than i try to use this array of objects, but its giving me the compile time error
&quot;Method getDistance() not found in class java.langObject.&quot;
Just to clarify, i made an array of objects in my Main to the class Vertices, than i pass it through to the Algorithm class and make an array called &quot;vertex&quot; use it like this...

if ( predecessor[j] == end )
{
if ( type.equals(&quot;D&quot😉 )
c = vertex[v].getDistance();
else
c = vertex[v].getTime();
}

but than it gives me that error whenever i call the method getDistance(). Help PLESAE!!
 
From what I can see...
it should be this...

public Algorithm( Object [] x, int size, int max ){
vertex = new Object[size];
for ( int i = 0; i < size; i++ ){
vertex = x;
}
}
 
try this again...It's not letting display what i need to...
public Algorithm( Object [] x, int size, int max ){
vertex = new Object[size];
for ( int i = 0; i < size; i++ ){
vertex/[i/] = x/[i/];
}
}

***disregard the &quot;/&quot;
 
Back
Top