Java valueOf () function

Source: Internet
Author: User

The ValueOf () method is used to return the value of the native number object for a given parameter, which can be a native data type, string, and so on.

This method is a static method. The method can receive two parameters one is a string, and the other is the cardinality.

Grammar

The method has the following syntax formats:

Staticinteger valueOf(int i)staticinteger valueOf(String  s)staticInteger valueOf(String s,int radix)   
Parameters
    • i --integer of the integer object.

    • s --the string of the Integer object.

    • Radix -the cardinality used when parsing the string s, which specifies the number of digits to use.

return value
    • integer valueOf (int i): Returns an integer instance representing the specified int value.

    • integer valueOf (String s): Returns an integer object that holds the value of the specified String.

    • integer valueOf (String s, int radix): Returns an integer object that holds the value extracted from the specified String when parsing with the cardinality provided by the second argument.

Instance
Public Class Test{ Public Static voidMain(StringArgs[]){IntegerX=Integer.ValueOf(9);DoubleC= Double.ValueOf(5);FloatA= Float.ValueOf("80");IntegerB= Integer.ValueOf("444",16); Using 16 binarySystem.Out.println(X);          System.  Out.         println(c);  System.  Out.         println(a);  System.  Out.     println(b);  }}< /c10> 

Compile the above program, the output result is:

95.080.01092  

Java valueOf () function

Related Article

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.