What is the finished code in Java? Some code to start is provided. Make it clear
ID: 3734016 • Letter: W
Question
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 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<Square> 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<Square> 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;
}
}
Explanation / Answer
Please find the fixed code and output below :
---------------------------
OUTPUT:
squareSet: [S:1, S:2, S:3]
original squareList: [S:1, S:2, S:2, S:3, S:3, S:3]
Rotated list: [S:2, S:3, S:3, S:3, S:1, S:2]
Are the second and third list elements equal?true
All list elements :
Decimal: 2 3 3 3 1 2
Binary: 10 11 11 11 1 10
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.