Small knowledge points in Java

Source: Internet
Author: User

1. Relevant knowledge points of data type

1.1. Conversion of Java built-in encapsulation class

The encapsulated classes built into Java, Byte, Integer, Float, double, and long can all be converted to numeric values of type double, because there are doublevalue () methods in these packaged classes. In turn, this method can be converted into a numeric value of type Double, "The reference object of each class declaration will have the corresponding Xxxvalue () method, converted to the data type you want "

Like what:

Package Fdx.test.shujukind;public class Testone {public static void main (string[] args) {byte b = new Byte ("12"); System.out.println ("b=" +b+ "     byte converted to double type:" +b.doublevalue ()); float f = new float ("123"); System.out.println ("f=" +f+ "     float converted to Double type:" +f.doublevalue ());D ouble d = new Double ("324"); System.out.println ("d=" +d+ "   double converts to double type:" +d.doublevalue ());}}

The results obtained:

B=12     byte to double type: 12.0f=123.0 float to double type     : 123.0d=324.0   double convert to double type: 324.0

Like what:

    

At the same time: All encapsulation classes (byte, short, Integer, Float, Double, Long) provide a static valueof (string s) method that converts the value of a given String type to the data type (byte, short , Integer, Float, Double, Long)

Like what:

  

1.2

Small knowledge points in Java

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.