Introduction to Java Programming _ first week (bottom)

Source: Internet
Author: User

Java Summary

    • Common code: Scanner in = new Scanner (system.in);
    • Usage of shortcut keys
      • Note: Crtl +/
      • Fast input: Alt +/Mac:option +/
      • Select line of code: SHIFT + up/down arrows

First, floating point number

Second, priority

Iii. type Conversion

1.1 Floating-point numbers-this does not fully display, the floating-point number conflicts with Int.

Solution:

      1. 12 instead of 12.0
      2. Modify inch
        • int inch change to double inch
        • Nextint instead of an int instead of a double nextdouble read in.
ImportJava.util.Scanner; Public classHello { Public Static voidMain (string[] args) {//TODO auto-generated Method Stub//5 feet, 7 inches tall? Conversion//formula (5+7)/12*0.3048        intFoot; intinch; Scanner in=NewScanner (system.in); Foot=In.nextint (); Inch=in.nextint ();//System.out.println (10/3);//The result can only be integers, 10 and 10.0 are different in Java 10.0 is a floating-point numberSystem.out.println ("foot=" + Foot + ", inch=" +inch);//View Output ResultsSystem.out.println ((FOOT+INCH/12) *0.3048); }}

1.2. How floating-point numbers are stored in the computer

2.1 Priority level

1. General operators: Thinking of normal thinking

2. Special operators:

    • Monocular operator
    • Binding Relationship-Assignment Operation result=a=b = 3+c (still thinking with conventional thinking)

3.1 Type conversions

Final display Results

Other examples

    • int i = 32/3.0;
    • int i = (int) (32/3.0); Values and types are bracketed, not changing the original value

Introduction to Java Programming _ first week (bottom)

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.