How To Use List in Java Programming Language
The Following script is the simplest way to declaring and using List in Java programming language:
import java.util.ArrayList;
import java.util.List;
public class UseList {
public static void main(String[] args) {
List<String> x = new ArrayList<>();
x.add("Ela");
x.add("Gracie");
x.add("Angelin");
x.add("Gracelyn");
//use functional operation
x.stream().forEach((y) -> {
System.out.println(y);
});
System.out.println();
//use new loop style
for(String z : x){
System.out.println(z);
}
}
}
output:
No comments:
Post a Comment