void (String[] args) { Runnable runnable = new Runnable() { @Override public void run() { Set<String> test = new HashSet<String>(); if (test.contains("AA")) { System.out.println("AAAA!"); } } }; runnable.run(); }