* 由于基本数据类型只能做一些简单的操作和运算,所以Java为我们封装了基本数据类型,为每种基本数据类型提供了包装类
* 包装类就是封装了基本数据类型的类,为我们提供了更多复杂的方法和一些变量

*
* byte Byte
* short Short
* char Character
* int Integer
* long Long
* float Float
* double Double
* boolean Boolean

* Integer:

* 构造方法:
* Integer(int value) int-- Integer
* Integer(String s) String--Integer * String --- int
* 方式1:
    Integer(String s) 对象的intValue()方法
*    int intValue()
*
* 方式2:
    static int parseInt(String s)
*
*
* int --- String
* 方式1: + ""
*
* 方式2:String toString()
* static String toString()

  

public class IntegerDemo {
public static void main(String[] args) { //String --- int
Integer i = new Integer("10");
int a = i.intValue();
System.out.println(a+10); int b = Integer.parseInt("5");
System.out.println(b+12); //int --- String
Integer i2 = new Integer(1);
String c = i2.toString();
System.out.println(c+21);//字符串的拼接 int d = 1;
String e = d + "";
System.out.println(e+212);//字符串的拼接
}
}

输出

28.5 Integer-- int的包装类的更多相关文章

  1. Java中 int和Integer的区别+包装类

    --今天用Integer 和Integer 比较 发现有问题,于是去查了查. 1.Java 中的数据类型分为基本数据类型和引用数据类型 int是基本数据类型,Integer是引用数据类型: Inget ...

  2. int和Integer的区别?包装类?装箱?拆箱?

    int和Integer的区别: 1) int是基本数据类型,直接存储的数值,默认是0; 2) Integer 是int的包装类,是个对象,存放的是对象的引用,必须实例化之后才能使用,默认是null; ...

  3. Java学习_int和Integer的区别+包装类

    1.Java 中的数据类型分为基本数据类型和引用数据类型 int是基本数据类型,Integer是引用数据类型: Ingeter是int的包装类,int的初值为0,Ingeter的初值为null. 2. ...

  4. list<Integer>,Integer[],int[]之间的互转(jdk1.8)

    偶然在开发过程中需要将int[] 转成 List<Integer>,采用了遍历的方式,写的代码实在太多. List<Integer> list = new ArrayList& ...

  5. String,Integer,int类型之间的相互转换

    String, Integer, int 三种类型之间可以两两进行转换 1. 基本数据类型到包装数据类型的转换 int -> Integer (两种方法) Integer it1 = new I ...

  6. 关于Integer 和Double包装类创建对象时的底层解析

    public void method1() { Integer i = new Integer(1); Integer j = new Integer(1); System.out.println(i ...

  7. IntegerCache缓存占用堆、栈、常量池的问题,自动拆装箱的基本概念,Integer==int时的问题说明

    原创声明:作者:Arnold.zhao 博客园地址:https://www.cnblogs.com/zh94 先普及一个基本概念:Java中基本数据类型的装箱和拆箱操作 自动装箱 在JDK5以后,我们 ...

  8. Integer & int & == & equals

    int 是基本类型,直接存数值,integer是对象,用一个引用指向这个对象 int 是基本数据类型,Integer是类 int类的变量初始为0,Integer的变量则初始化为null. 如果只是用来 ...

  9. mysql Integer Types (Exact Value) - INTEGER, INT, SMALLINT, TINYINT, MEDIUMINT, BIGINT

    使用mysql的时候,用到int类型的蛮多,需要注意一下: 1. 值的范围 Type Storage Minimum Value Maximum Value   (Bytes) (Signed/Uns ...

  10. Java中List, Integer[], int[]的相互转换

    import java.util.Arrays; import java.util.List; import java.util.stream.Collectors; public class Mai ...

随机推荐

  1. (转).balignl 16,0xdeadbeef浅析

    原文地址:http://zqwt.012.blog.163.com/blog/static/12044684201031102956976/ 最近在分析u-boot的源代码,看到这一行: .balig ...

  2. svn 追责神器 blame vscode - SVN Gutter

    svn 追责神器 blame vscode - SVN Gutter

  3. 分享几个 PHP 编码的最佳实践

    对于初学者而言,可能很难理解为什么某些做法更安全. 但是,以下一些技巧可能超出了 PHP 的范围. 始终使用大括号 让我们看下面的代码: if (isset($condition) && ...

  4. Java 并发容器(转)

    转自:https://blog.ouyangsihai.cn/%2Fjava-gao-bing-fa-zhi-bing-fa-rong-qi-xiang-jie-cong-ru-men-dao-cha ...

  5. cmdb客户端代码完善2

    目录: 1.面试提问 2.完善采集端代码 3.唯一标识的问题 4.API的验证 1.面试会问到的问题: # 1. 为啥要做CMDB?# - 实现运维自动化, 而CMDB是实现运维自动化的基石# - 之 ...

  6. 树莓派4B踩坑指南 - (13)用samba建立家庭局域网共享中心

    树莓派在家中至少三个作用:家庭资源共享中心.无线打印服务器.下载服务器. 家庭资源共享中心用samba实现家庭局域网共享,树莓派4B的话可以接2个3.0的移动硬盘. 实测速度不快,Win读2Mb/s写 ...

  7. [贪心]Codeforces Equal Rectangles

    Equal Rectangles time limit per test 2 seconds memory limit per test 256 megabytes input standard in ...

  8. vim-1-window,buffer and tab

    Summary:A buffer is the in-memory text of a file. A window is a viewport on a buffer. A tab page is ...

  9. OpenCV -Python 性能衡量和提升技术 | 十二

    目标 在图像处理中,由于每秒要处理大量操作,因此必须使代码不仅提供正确的解决方案,而且还必须以最快的方式提供.因此,在本章中,你将学习 衡量代码的性能. 一些提高代码性能的技巧. 你将看到以下功能:c ...

  10. ​GAN的五大有趣应用

    引言 你能看出这张照片中面部的共同点吗? 这些人都不是真实存在的!这些面部图像都是由GAN技术生成的. "GAN"这个词是由Ian Goodfellow在2014年提出的,但相关概 ...