Package demo; Public class Test { publicstaticvoid main (string[] args) { // TODO Auto-generated method stubs Object[] arr={"A", "B", and; System.out.println (arr);} }
The code above can be compiled smoothly and output a "very strange" result: Ljava.lang.Object; @ba8a1dc
This error is a very common error, the error hints are clear, that is, the Java object array can not be converted to string[] array, which means that the array you want to convert it itself is an array of type object, but you do not want to convert it into an array of string class, Of course it's wrong. When encountering a type conversion error, the first thing to observe is the original type of the object being converted, this need to first convert it into its own type of object, and then according to the object to manipulate the elements inside, again the type of conversion, and sometimes the object of the analysis may have multiple layers of packaging, In the process of conversion needs to be multi-layered to untie her, like a cabbage, a layer of peel off its original type until the final type of the object is obtained, and then convert the type that cannot be decomposed into the object of its own target type
Ljava.lang.Object; @ba8a1dc problem