For the code belong, I'm trying to compare all the objects with each other and print if they're the same, is there any efficient methods in doing so beside me creating like 20 if else statement and compare each object individually? Thanks
import java.util.*; public class TestHomework3 { public static void main(String[]args) { List<Homework3> workArray= new ArrayList<Homework3>(); MyMath3 math = new MyMath3(); MyScience3 science = new MyScience3(); MyEnglish3 english = new MyEnglish3(); MyJava3 java = new MyJava3(); workArray.add(math); workArray.add(science); workArray.add(english); workArray.add(java); math.createAssignment(4); science.createAssignment(6); english.createAssignment(4); java.createAssignment(5); for(int x = 0 ; x < workArray.size();x++) { System.out.println(workArray.get(x).toString()); } if(workArray.get(0).compareTo(workArray.get(1)) == 0 ) System.out.println("The same"); else System.out.println("Differents"); } }