Am I doing something wrong? I'm using Java 1.6.15 on windows and I try the following code which gives a class cast exception:
import java.util.Arrays;
public class NameTest {
public static void main( String[] args ) {
try {
double[] tmp = new double[1];
tmp[0] = 1.5;
print( tmp );
} catch ( Exception e ) {
System.out.println( "Exception: " + e.getMessage() );
}
Double[] tmp1 = new Double[1];
tmp1[0] = 1.5;
print( tmp1 );
double[][] tmp2 = new double[1][1];
tmp2[0][0] = 1.5;
print( tmp2 );
}
static void print( Object tmp ) {
System.out.println( "Test =" + Arrays.deepToString( (Object[]) tmp ) );
}
}
Output :
Exception: [D cannot be cast to [Ljava.lang.Object;
Test =[1.5]
Test =[[1.5]]