import java.util.ArrayList;import java.util.List; class Ideone { public static void main(String[] args) { List<Integer> dates = new IntegerPrinter().anyPrint(7); System.out.println(dates.get(0)); Integer x = dates.get(0); }} class IntegerPrinter { public <K> List<K> anyPrint(K lo) { List<K> mylist = new ArrayList<>(); mylist.add((K) Float.valueOf(2.99f)); return mylist; }}
Standard input is empty
2.99
Exception in thread "main" java.lang.ClassCastException: class java.lang.Float cannot be cast to class java.lang.Integer (java.lang.Float and java.lang.Integer are in module java.base of loader 'bootstrap') at Ideone.main(Main.java:8)
The brand new service which powers Ideone!
Widget for compiling and running the source code in a web browser!