Ljava.lang.Object; @ba8a1dc problem

Source: Internet
Author: User


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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.