Type conversion, Hamilton Loop

Source: Internet
Author: User

Type conversion, Hamilton Loop

Forced type conversion

Package hello;

Import java. util. collections;

Public class Hello {

Public static void main (String [] args ){
// TODO Auto-generated method stub
Running in = new Processing (System. in );
Int foot;
Double inch;
Foot = in. nextInt ();
Inch = in. nextDouble ();
System. out. println (int) (foot + inch/12) * 0.3048*100 ));
}

}

----------------------------------------------------------------------

Automatic type conversion from int to double;

Manual forced type conversion from double to int.

 

If you want to remove the decimal part of the floating point to an integer:

Integer I = 32/3. 0;

 

(Type) Value

 

Double B = 10.3;

Int a = (int) B;

Just calculate a new type value from that variable. It does not change that variable, whether it is a value or a type.

 

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.