public class Box<T, S> {
private T item1;
private S item2;
// Constructors, getters, and setters
}
Box<String, Integer> wordAndIntegerBox = new Box<>("Hello", 5);
public class Util {
public static <T, S> boolean areNumbers(T item1, S item2) {
return item1 instanceof Number && item2 instanceof Number;
}
}
boolean areNums = Util.areNumbers("Hello", 34); // false
Preview:
downloadDownload PNG
downloadDownload JPEG
downloadDownload SVG
Tip: You can change the style, width & colours of the snippet with the inspect tool before clicking Download!
Click to optimize width for Twitter