Create a Java program to demonstrate the use of interfaces with generics
interface Container<T> { T getValue(); void setValue(T value); } class MyContainer<T> implements Container<T> { private T value; @Override public T getValue() { return value; } @Override public void setValue(T value) { this.value = value; } } public class Main { public static void main(String[] args) { Container<Integer> container = new MyContainer<>(); container.setValue(42); System.out.println("Value : " + container.getValue()); } }
Value : 42
Learn All in Tamil © Designed & Developed By Tutor Joes | Privacy Policy | Terms & Conditions