I got a array of objects. From another method i want to print one object from the array, the input to this method must be an integer, that represent the index of the object in the array. I can't reach the array from printObject(). How do i do this?
public static void main(String[] args) {
Object []obj = new Object[2];
printObject(1);
}
public static void printObject(int i){
if (i == 0){
System.out.println(obj[0].toString());
}
if (i == 1){
Systen.out.println(obj[1].toString());
}
}