7.1 String类对象实例化

public class HelloWorld {
    public static void main(String[] args){
        //String str = "www.mldn.cn";// 直接赋值-String类对象实例化
        String str = new String("www.baidu.com");// 构造实例化-String类对象实例化
        System.out.println(str);
    }
    // jdk1.8以前 String char形式保存
    // jdk1.9之后 String byte形式保存
}

  • 2种赋值方法有什么区别.
posted @ 2023-06-06 14:24  盘思动  阅读(9)  评论(0)    收藏  举报