Mon Dec 13, 2010 11:28 am
public class myanimallist
{
private animal[] animals = new animal[5];
private int nextindex = 0;
public void add(animal a)
{
if(nextindex < animals.length)
{
animals[nextindex] = a;
System.out.print("animal added at " + nextindex);
nextindex++;
}
}
}
public class animal
{
public static void main(String[] args)
{
myanimallist list = new myanimallist();
dog d = new dog();
cat c = new cat();
list.add(d);
list.add(c);
}
}
Fri Jan 07, 2011 1:20 am
Fri Jan 07, 2011 1:23 am
Codemiles.com is a participant in the Amazon Services LLC Associates Program, an affiliate advertising program designed to provide a means for sites to earn advertising fees by advertising and linking to Amazon.com
Powered by phpBB © phpBB Group.