Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- class apples{
- public static void main(String[] args){
- DogList DLO = new DogList();
- Dog d = new Dog();
- DLO.add(d);
- }
- }
- public class Fish extends Animal{
- }
- public class Dog extends Animal{
- }
- public class Animal {
- }
- public class DogList {
- private Dog[] thelist = new Dog[5];
- private int i=0;
- public void add(Dog d){
- if(i<thelist.length){
- thelist[i]=d;
- System.out.println("Dog added at index "+i);
- i++;
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement