3. Output, input, basic data type

Source: Internet
Author: User

1. Output

Package Com.example;public class MyClass {    public  static void Main (String args[]) {        System.out.println ( Byte.min_value + "~" + byte.max_value);        System.out.println (Integer.parseint (")");        System.out.println (Integer.tobinarystring ());        System.out.println (Integer.tohexstring ());        System.out.println (integer.tostring);}    }

2. Enter

Package Com.example;import Java.util.scanner;public class MyClass {public    static void Main (string[] args) {        // Scanner input data from the console        Scanner Scanner = new Scanner (system.in);        System.out.println ("Name:");        String name = Scanner.next ();        System.out.println ("Gender:");        char sex = Scanner.next (). charAt (0);        System.out.println ("Age:");        int age = Scanner.nextint ();        System.out.println ("height");        Double height = scanner.nextdouble ();        System.out.print ("character");        String type = Scanner.next ();        SYSTEM.OUT.PRINTLN ("Hi everyone, I am:" +name+ ", Gender:" +sex+ ", Age:" +age+ ", Height:" +height+ ", Character:" +type "); rain, female, 22, 1.62, haha           }}

3. Basic data types and their conversions

Package Com.example;public class MyClass {    public  static  void  main (string[] args) {        //1.        Long longvalue = 3000000000l;        2.        Auto-turn: Byte->short->int->long        //strong turn: Long->ing->short->byte        //3.        BYTE B1 = 5;        Because an integer is stored internally as int        //So byte B3 = B1 + 3 is wrong and can be changed to the following two forms:        byte b2 = (byte) (B1 + 3);        int B3 = B1 + 3;        1.        float c = 4.3f;        2.        Auto-turn: float->double        //strong turn: Double->float        //char Type: characters, Kanji, English letters, by ' wide up        //bool type: True and False    }}

3. Output, input, basic data 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.