Hi!
Could someone please tell me how can I create an obejct of the Class1 shown below? Let's say I want initialize the List of subjects. I try the following code, but it doesn't work:
List<ClassInterface> myInterface;
myInterface = Class1.getAllSubjects();
Thanks!
public class Class1
{
public List<ClassInteface> getAllSubjects()
{
List<ClassInteface> subjects = new ArrayList<ClassInteface>();
try
{
Thread.sleep(3 * 100);
}
catch (InterruptedException e)
{
//
}
subjects.add(new MySubject("Subject 1"));
subjects.add(new MySubject("Subject 2"));
subjects.add(new MySubject("Subject 3"));
return subjects;
}
}
public class MySubject implements ClassInterface
{
private String result = "";
private String name = "";
public MySubject(String name)
{
this.name = name;
}
public String getName()
{
return name;
}
public String getResult()
{
return result;
}
}