首页 > 代码库 > 3.输出,输入,基本数据类型

3.输出,输入,基本数据类型

1.输出

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("1000"));
        System.out.println(Integer.toBinaryString(100));
        System.out.println(Integer.toHexString(100));
        System.out.println(Integer.toString(200));
    }
}

 2.输入

package com.example;

import java.util.Scanner;

public class MyClass {
    public static void main(String[] args){
        //scanner从控制台输入数据
        Scanner scanner = new Scanner(System.in);

        System.out.println("姓名:");
        String name = scanner.next();

        System.out.println("性别:");
        char sex = scanner.next().charAt(0);

        System.out.println("年龄:");
        int age = scanner.nextInt();

        System.out.println("身高");
        double height = scanner.nextDouble();

        System.out.print("性格");
        String type = scanner.next();

        System.out.println("嗨,大家好,我是:"+name+",性别:"+sex+",年龄:"+age+",身高:"+height+",性格:"+type);
小雨,女,22,1.62,哈哈

       
    }
}

 3.基本数据类型及其转换

package com.example;

public class MyClass {
    public  static  void  main(String[] args){
        //1.
        long longValue = http://www.mamicode.com/3000000000l;>

 

3.输出,输入,基本数据类型