Files
Story-With-Thanh/J07006 - SỐ KHÁC NHAU TRONG FILE - 3.java
T
2022-12-15 23:51:04 +07:00

18 lines
600 B
Java

import java.util.*;
import java.io.*;
public class Main{
public static void main(String[] args) throws IOException, FileNotFoundException, ClassNotFoundException {
ObjectInputStream is = new ObjectInputStream(new FileInputStream("DATA.in"));
TreeMap<Integer, Integer> a = new TreeMap<>();
ArrayList<Integer> l = (ArrayList<Integer>) is.readObject();
l.forEach( x -> {
if(a.get(x) == null) a.put(x, 1);
else a.put(x, a.get(x)+1);
});
a.forEach((k,v) -> {
System.out.printf("%d %d\n", k , v);
});
}
}