Add one, two, three Strings to the list field in the provided order.
What are collections
Initialize a collection
Report a typo
Write a program in Java 17
import java.util.ArrayList;
class Main {
ArrayList<String> list = new ArrayList<>();
void init() {
// add "one", "two", "three" to list field in this order
}
}
class Test {
public static void main(String[] args) {
Main main = new Main();
main.init();
for (String str : main.list) {
System.out.println(str);
}
}
}
___
By continuing, you agree to the JetBrains Academy Terms of Service as well as Hyperskill Terms of Service and Privacy Policy.
Create a free account to access the full topic
By continuing, you agree to the JetBrains Academy Terms of Service as well as Hyperskill Terms of Service and Privacy Policy.