Java ArrayList Printing Elements
Go to solution
Solved by Zindokar,
If you override the toString(): string method to your data class, which is jobSchedule (rename to JobSchedule), you will be able to do:
System.out.println(array.get(i)); // automatically will try to get toString method of JobSchedule, since you did not override, it will get toString method from Object
Something like:
@Override public string toString() { return "[" + this.ID + ": " + this.runtime + "]"; // you can personalize your output here }
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now