Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

What is the finished code in Java? Some code to start is provided. Make it clear and easy to understand. package generics; import java.util.ArrayList; import

What is the finished code in Java? Some code to start is provided. Make it clear and easy to understand.

image text in transcribed

package generics;

import java.util.ArrayList; import java.util.Arrays; import java.util.Collections; import java.util.HashSet; import java.util.List; import java.util.Set;

public class ExampleGenerics {

public static void main(String[] args) { Set squareSet = new HashSet(Arrays.asList(new Square(1), new Square(2), new Square(2), new Square(3), new Square(3), new Square(3))); System.out.println("squareSet: " + squareSet); List squareList = new ArrayList(Arrays.asList(new Square(1), new Square(2), new Square(2), new Square(3), new Square(3), new Square(3))); System.out.println("original squareList: " + squareList); } }

--------------------------------------------------------------------------------------------------------------

package generics;

public class Square { private int side;

public Square(int side) { this.side = side; }

public int getSide() { return side; }

public void setSide(int side) { this.side = side; }

@Override public String toString() { return "S:" + side; } }

ExampleGenerics: Part A . Run ExampleGenericcs.java You see that the set includes multiple squares with the same side length . Make the necessary changes to class Square so that two squares with the same side length are recognized as equal When you are done run the code. Now the set should include only squares with different side lengths Expected Output: bag: [S:1, S:2, S:3] original list: Part B; Rotate all the list elements by 2 elements to the left. . Compare the content of the second and third list elements [S:1, S:2, S:2, S:3, S:3, S:3] Answer the question of the prompt with yes or now depending on the content of the squares The result should still be correct when I change the original list elements rotated list : [S:2, S:3, S:3, S:3, S:1, S:2] Are the second and yes third list elements equal? All list elements: decimal: 2 3 3 31 2 Print the side lengths of all squares in the list twice Align the values in equally spaced columns First print them in decimal format (as usual) Then print them in binary format Format the output and use labels as shown in the example below

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Database Design And SQL For DB2

Authors: James Cooper

1st Edition

1583473572, 978-1583473573

Students also viewed these Databases questions