GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • java.evolved

This view

  • Original page
  • New address

GeezerVison is showing javaevolved.dev — Generics — java.evolved

Home / Topics / Generics
🏷 Generics 2 patterns

Topic: Generics

All Java patterns related to Generics — java.evolved

Language

Diamond with anonymous classes

Old Map<String, List<String>> map = new HashMap<String, List<String>>(); // anonymous class: no diamond Predicate<String> p = new Predicate<String>() { public boolean test(String s) {..} };
Modern Map<String, List<String>> map = new HashMap<>(); // Java 9: diamond with anonymous classes Predicate<String> p = new Predicate<>() { public boolean test(String s) {..} };
hover to see modern →
JDK 9+ learn more →
Language

Raw collections to generic types

Old List names = new ArrayList(); names.add("Duke"); String name = (String) names.get(0);
Modern List<String> names = new ArrayList(); names.add("Duke"); String name = names.get(0);
hover to see modern →
JDK 5+ learn more →
You are visitor 01402520 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.