Main.java Source code

Java tutorial

Introduction

Here is the source code for Main.java

Source

Size = 0, Elements = []
import java.util.ArrayList;
import java.util.Collection;

public class Main {
  public static void main(String[] args) {
    Collection<String> names = new ArrayList<>();
    System.out.printf("Size = %d, Elements = %s%n", names.size(), names);
    names.add("XML");
    names.add("HTML");
    names.add("CSS");
    System.out.printf("Size   = %d, Elements   = %s%n",
        names.size(), names);
    names.remove("CSS");
    System.out.printf("Size   = %d, Elements   = %s%n",
        names.size(), names);
    names.clear();
    System.out.printf("Size   = %d, Elements   = %s%n",
        names.size(), names);
  }
}