Complete the code to import the ArrayList class from java.util package.
import java.util.[1]; public class Main { public static void main(String[] args) { ArrayList<String> list = new ArrayList<>(); } }
The ArrayList class is in the java.util package, so you import it with import java.util.ArrayList;.
Complete the code to import all classes from the java.io package.
import java.io[1]; public class Main { public static void main(String[] args) { // code using java.io classes } }
To import all classes from a package, use .* after the package name, like import java.io.*;.
Fix the error in the import statement to correctly import the HashMap class.
import java.util.[1]; public class Main { public static void main(String[] args) { HashMap<String, Integer> map = new HashMap<>(); } }
Java is case-sensitive. The correct class name is HashMap with capital M.
Fill both blanks to import the Scanner class and create a Scanner object.
import java.util.[1]; public class Main { public static void main(String[] args) { [2] scanner = new Scanner(System.in); } }
You import the Scanner class and declare a variable of type Scanner to create the object.
Fill all three blanks to import the List interface, declare a List variable, and initialize it with an ArrayList.
import java.util.[1]; import java.util.[2]; public class Main { public static void main(String[] args) { [3]<String> list = new ArrayList<>(); } }
You import both List and ArrayList classes. Then declare a variable of type List and initialize it with an ArrayList object.
