Autoboxing and Autounboxing

前言:

  • 首先我们要知道Java中有哪些基本数据类型以及它们各自的封装类:package java.lang;
基本数据类型封装类
byteByte
booleanBoolean
charCharacter
shortShort
intInteger
longLong
floatFloat
doubleDouble

Java中常量池详解

阅读这篇文章之前先来理解几个基本的概念

  • 什么是常量
  • equals()方法和==的区别
  • 引用和对象的区别

1. String常量池

1.1 创建String对象的两种方式

  • 通过new来创建String创对象,例如:String a = new String(“a”);

  • 直接将字符串常量赋值给一个对象引用,例如:String b = “b”;

    这两种不同的创建方法是有差别的,第一种方式是直接在Java heap内存空间创建一个新的对象,并且引用变量a指向这个对象,第二种方式是引用变量b指向常量池中的字符串。

java中“...”的含义

  1. 问题来源

    在阅读spring源码时发现问题:

    1
    2
    3
    4
    5
    6
    7
    8
    9
    /**
    * Create a new ClassPathXmlApplicationContext, loading the definitions
    * from the given XML files and automatically refreshing the context.
    * @param configLocations array of resource locations
    * @throws BeansException if context creation failed
    */
    public ClassPathXmlApplicationContext(String... configLocations) throws BeansException {
    this(configLocations, true, null);
    }
Your browser is out-of-date!

Update your browser to view this website correctly. Update my browser now

×