LogiQuest
Back to Generics
8

What is the output of the following program?

public class Main {
    static class Box<T> { T v; Box(T v) { this.v = v; } T get() { return v; } }
    public static void main(String[] args) {
        Box<Integer> b = new Box<>(41);
        System.out.println(b.get() + 1);
    }
}
Easy

Discussion (0)

  • No discussion yet. Ask a doubt or share a shortcut.

Log in to join the discussion.