Java tells me it can't find getName() when i try to run the main method. I'm not sure why, I've looked around stackexchange to no avail. It seems like such a simple solution but I can't seem to figure it out.
import java.util.*;
public class ArrayTester
{
public static ArrayList<Object> array;
public static void main(String args[])
{
array = new ArrayList<Object>();
array.add(new TestObject("Some Name"));
System.out.println("Object Name: " + array.get(0).getName());
}
}
Object:
public class TestObject
{
private String name;
public TestObject(String cname){
name = cname;
}
public String getName(){
return name;
}
}
Thanks for your help in advance. I apologize if there is an identical question somewhere that I didn't see.