Java Reference
In-Depth Information
}
String getName()
{
return name;
}
String getDesc()
{
return desc;
}
@Override
public String toString()
{
return "Name = "+getName()+", Desc = "+getDesc();
}
}
You next create a ToDoList class to store ToDo instances. ToDoList uses its
ToDoArray nonstaticmemberclasstostore ToDo instancesinagrowablearray-you
donotknowhowmanyinstanceswillbestored,andJavaarrayshavefixedlengths.See
Listing 3-8 .
Listing 3-8. Storing a maximum of two ToDo instances in a ToDoArray instance
class ToDoList
{
private ToDoArray toDoArray;
private int index = 0;
ToDoList()
{
toDoArray = new ToDoArray(2);
}
boolean hasMoreElements()
{
return index < toDoArray.size();
}
ToDo nextElement()
{
Search WWH ::




Custom Search