CodeGym /Courses /Java Collections /Big task: Java collections Big task: Java collections Java Collections Level 4 , Lesson 15 Available "Hello, soldier!" "Congratulations on upgrading your skills. We need guys who are prepared to do anything." "I'm sure you still have many unfinished tasks. It's time to finish some of them!" 8 Task Java Collections, level 4, lesson 15 Locked AmigoSet (part 1) AmigoSet (part 1) 30 Task Java Collections, level 4, lesson 15 Locked AmigoSet (part 2) AmigoSet (part 2) 14 Task Java Collections, level 4, lesson 15 Locked AmigoSet (part 3) AmigoSet (part 3) 14 Task Java Collections, level 4, lesson 15 Locked AmigoSet (part 4) AmigoSet (part 4) 30 Task Java Collections, level 4, lesson 15 Locked AmigoSet (part 5) AmigoSet (part 5) 8 Task Java Collections, level 4, lesson 15 Locked AmigoSet (part 6) AmigoSet (part 6) Comments (4) TO VIEW ALL COMMENTS OR TO MAKE A COMMENT, GO TO FULL VERSION Skynet Level 40, USA 28 September 2021 Test code for part 5: HashSet<String> hashSet = new HashSet<>(); hashSet.add("String 1"); hashSet.add("String 2"); AmigoSet amigoSet1 = new AmigoSet(hashSet); ByteArrayOutputStream baos = new ByteArrayOutputStream(); ObjectOutputStream oos = new ObjectOutputStream(baos); oos.writeObject(amigoSet1); oos.close(); ByteArrayInputStream bais = new ByteArrayInputStream(baos.toByteArray()); ObjectInputStream ois = new ObjectInputStream(bais); AmigoSet amigoSet2 = (AmigoSet) ois.readObject(); System.out.println("Before serialization:\n" + amigoSet1 + "\n"); System.out.println("After deserialization:\n" + amigoSet2 + "\n"); System.out.println("Are sets equal? - " + amigoSet1.equals(amigoSet2)); Nicholas Grube Level 41, Carrollton, TX, United States 22 June 2020 Hint for task 5: Look at what data type loadFactor is (it's not the same type as Capacity). yz Level 37, Jakarta, Indonesia 8 April 2020 if u need help for 5th one text me Seb Level 41, Crefeld, Germany 21 February 2020 Woohoo - task 5 was a little bit of a refresher in terms of serialization. Pretty cool to use this in conjunction with the provided HashMapReflectionHelper. Thank you, Captain Squirrels, Sir! :-)
GO TO FULL VERSION