-1

When I run a program in eclipse I get ClassCastException but when i run it in cmd it does not crash. what is wrong in eclipse? It is the return statement i get the error.

    private static <T> T[] tilArray(Tabell<T> tabellen)
    {
        T[] ut = (T[])new Object[tabellen.storrelse()];
        int pos = 0;
        for(T element : tabellen)
        {
            ut[pos++] = element;
        }
        return ut;
    }

2 Answers2

0

It's because the JDK version used in Eclipse is different from system JAVA_HOME.

Shawn Xiong
  • 470
  • 3
  • 14
0

You can try to change the version used in eclipse and how to do that please see the already existing link:

Setting JDK in Eclipse

Community
  • 1
  • 1
drink-a-Beer
  • 389
  • 1
  • 5
  • 14