JAVA#包装类'学习札记

1.Wrapper:基本数据类型对应的基本数据类型类即为包装类;

2.

基本数据类型

包装类

          boolean

          Boolean

          byte

          Byte

          short

          Short

          int

          Integer

          long

          Long

          char

          Character

          float

          Float

          double

          Double

3.1️⃣基本数据类型==》包装类

Integer allen=new Integer (3);

Float allen=new Float("12.3F");

Boolean allen=new Boolean("true");

2️⃣包装类==》基本数据类型(调用包装类的Aaa的AaaValue()方法)

int allen=iverson.intValue();

float allen=allen.floatValue();

boolean allen=allen.booleanValue();

3️⃣基本数据类型,包装类==》String类(调用String类的重载valueOf(Aaa a)方法)

int allen=3;

String iverson=allen+" ";

Integer allen=kobe;

String iverson=String.valueOf(allen);

String allen=String.valueOf(true);

4️⃣String类==》基本数据类型,Wrapper类(调用包装类的parseAaa(String iverson)方法)

int allen=Integer.parseInt(iverson);

boolean allen=Boolean.parseBoolean(iverson);

public class Superman{
    public static void main(String[] args) {
        Integer allen=3;
        String james=3+"";
        System.out.print(allen);
        System.out.print(james);
        String kobe=String.valueOf(allen);
        System.out.print(kobe);
        int wade=Integer.parseInt(kobe);
        System.out.print(wade);



    }
}
3333

猜你喜欢

转载自blog.csdn.net/Iverson941112/article/details/82080622
今日推荐