Conversation
auberonedu
left a comment
There was a problem hiding this comment.
Nice job! See comments below
| public class ListPractice { | ||
| public static void main(String[] args) { | ||
| // Create an empty ArrayList of Strings and assign it to a variable of type List | ||
| ArrayList<String> myList = new ArrayList<>(); |
There was a problem hiding this comment.
Remember to use interface types (List)
| public static void main(String[] args) { | ||
| // Create a HashMap with String keys and Integer values and | ||
| // assign it to a variable of type Map | ||
| HashMap<String, Integer> map = new HashMap<>(); |
There was a problem hiding this comment.
Remember to use interface types (Map)
| public int birthYear(int age, int currentYear) { | ||
| return currentYear - age; | ||
| } |
There was a problem hiding this comment.
This doesn't quite match the Javadoc description. It should only take a single argument, currentYear. The age is already stored as an instance variable, so you don't need to get it again as an argument
| public class SetPractice { | ||
| public static void main(String[] args) { | ||
| // Create a HashSet of Strings and assign it to a variable of type Set | ||
| HashSet<String> set = new HashSet<>(); |
There was a problem hiding this comment.
Remember to use interface types (Set)
|
|
||
| // Create an ArrayList of Strings and assign it to a variable | ||
|
|
||
| ArrayList<String> list = new ArrayList<>(Arrays.asList("Strawberry", "Banana", "Grape")); |
There was a problem hiding this comment.
Remember to use interface types (List)
| // Check whether two strings are equal | ||
| String a = "Lol"; | ||
| String b = "Lolo"; | ||
| System.out.println(a == b); |
There was a problem hiding this comment.
Strings in Java should typically be compared using .equals, not == (see the comment that was at the bottom of this file)
No description provided.