Hash set

import java.util.*;

public class MyApp {

	public static void main(String[] args){
		// HashSet
		HashSet<Integer> sales = new HashSet<>();

		sales.add(10);
		sales.add(20);
		sales.add(30);
		sales.add(10);

		System.out.println(sales.size());

		for(Integer sale: sales){
			System.out.println(sale);
		}

		sales.remove(30);

		for(Integer sale: sales){
			System.out.println(sale);
		}
	}
}

[vagrant@localhost java]$ javac MyApp.java
[vagrant@localhost java]$ java MyApp
3
20
10
30
20
10

import java.util.*;

public class MyApp {

	public static void main(String[] args){
		
		// HashMap<String, Integer> sales = new HashMap<>();
		Map<String, Integer> sales = new HashMap<>();

		sales.put("tom", 10);
		sales.put("bob", 20);
		sales.put("steve", 30);

		System.out.println(sales.get("tom"));
		System.out.println(sales.size());

		for (Map.Entry<String, Integer> sale: sales.entrySet()){
			System.out.println(sale.getKey() + ":" + sale.getValue());
		}

		sales.put("tom", 100);
		sales.remove("steve");

		for (Map.Entry<String, Integer> sale : sales.entrySet()){
			System.out.println(sale.getKey() + ":" + sale.getValue());
		}
	}
}
import java.util.*;

public class MyApp {

	public static void main(String[] args){
		
		List<Integer> sales = new ArrayList<>(Arrays.asList(12, 30, 22, 4, 9));
		sales
			.stream()
			.filter(e -> e % 3 == 0)
			.map(e -> "(" + e + ")")
			.forEach(System.out::println);

		System.out.println();
	}
}
import java.time.*;
import java.time.format.DateTimeFormatter;

public class MyApp {

	public static void main(String[] args){
		LocalDateTime d = LocalDateTime.now();
		System.out.println(d.getYear());
		System.out.println(d.getMonth());
		System.out.println(d.getMonth().getValue());
		System.out.println(d.plusMonths(2).minusDays(3));
		DateTimeFormatter dtf = DateTimeFormatter.ofPattern("yyyy!MM!dd!");
		System.out.println(d.format(dtf));
	}
}

[vagrant@localhost java]$ javac MyApp.java
[vagrant@localhost java]$ java MyApp
2018
SEPTEMBER
9
2018-11-13T23:12:54.812
2018!09!16!