Java.lang.Integer cannot is cast to java.lang.String Java Int,double conversion to string and string to int,double conversions __string

Source: Internet
Author: User

Count=integer.parseint ((String) all.get (0));

Implementation times error: Java.lang.ClassCastException:java.lang.Integer cannot be cast to java.lang.String

Workaround: Change the red-flagged statement to Count=integer.parseint (all.get (0). toString ());

The operational problems of this type of cast often appear in the database query with count (), sum () and other data results, pay attention to the conversion method, to prevent the error.

The conversion of Java int,double to string and the conversion of string to Int,double

Double a=double.valueof (m_textstring). Doublevalue ();//string convert to Double

Str=string.valueof (c);//double,int converted to String

int int=integer.valueof (str);//string converted to int

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.