Java tutorial
//package com.java2s; import android.app.Notification; import java.util.LinkedHashMap; import java.util.Map; import java.util.Set; public class Main { private static Map<Integer, Notification> mapNotify = new LinkedHashMap<>(); private synchronized static int getLastKey() { Set<Integer> set = mapNotify.keySet(); if (set.size() == 0) { return 0; } return (int) set.toArray()[set.size() - 1]; } }