/** * Simple example of GENERIC inner classes * @author gtowell * Created: Mar 2021 * Modified: Jul 2021 */ public class OutCLGen { /** * The inner class, Generically */ private class InnCl { private Y value1; // a value private Z value2; // another value public InnCl(Y v1, Z v2) { this.value1 = v1; this.value2 = v2; } public String toString() { return value1 + " " + value2; } } /** * Use the inner class */ public void worker(R rValue, S sValue) { InnCl icl1 = new InnCl<>(1, "Bob"); InnCl icl2 = new InnCl<>(rValue, sValue); icl1.value1 = 3; System.out.println(icl1 + "\n" + icl2); } public static void main(String[] args) { OutCLGen ocl = new OutCLGen<>(); ocl.worker(42, "Carol"); } }