Java Programming assigment
For your program:
Create a data class namedAutomobile that implements the Comparable interface. Give the class data fields for make, model, year, and price. Then add a constructor, all getters, a toString method that shows all attribute values, and implement Comparable by using theyear as the criterion for comparing instances.
Write a program namedTestAutos that creates an ArrayList of five or six Automobiles. Use a for loop to display the elements in the ArrayList. Sort the Arraylist of autosby year with Collections.sort(). Finally, use aforeach loop to display the ArrayList sorted by year.
Already registered? Login
Not Account? Sign up
Enter your email address to reset your password
Back to Login? Click here