Hello guys I have a question. I have an error when I am trying to pass an array of object to a method My class
public class Object {
private int x1;
public Object(int a ,){
this.x1=a;
}
public class staticMethods{
public static void findMaxPos(Object[] name){
max = name[0]
pos = 0
for( int i=1; i<name.length ; i++){
if ( name[i] >max ){
max = name[i];
pos = i;
}
}
}
public class Example{
public static void main(String[] args) {
Object[] yp = new Object2[3];
yp[0] = new Object(5);
yp[1] = new Object(6);
yp[2] = new Object(8);
findMaxPos(type)// i get an error of the method findMaxPos is undefined for the type Example
}
So sorry for the long post ...
staticMethods.findMaxPospublic Object(int a ,)is incomplete. Also it is probably a really bad idea to have a class named Object, since that is also the name of the class at the root of the Java class hierarchy. It can become really confusing when reading code.