how do I print all elements in an ArrayList??
this my code below.

import java.util.ArrayList;
 * Write a description of class PetDatabase here.
 * @author (your name) 
 * @version (a version number or a date)
public class PetDatabase
    private String name;
    private String species;
    private int insurance;
    private ArrayList<Pets>pets;

    public PetDatabase()
        pets = new ArrayList<Pets>();

    public int Size()
       return pets.size();

    public void petRecord(String name,String species,int insurance)
       Pets can = new Pets();
    public void PrintAll()


Recommended Answers

All 2 Replies

and, to avoid getting 'weird' results, don't forget to override the toString method in your Pet class.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.