标签:public stat package code pre ring out void 区分大小写
Java中判断字符串是否相等应使用equals,==运算符比较的是两个字符串是否在同一个位置上。
package com.company;
public class Main {
    public static void main(String[] args) {
        String greeting = "Hello";
        System.out.println("Hello".equals(greeting));//true
        //不区分大小写
        System.out.println("Hello".equalsIgnoreCase("hello"));//true
        System.out.println(greeting=="Hello");//true
        System.out.println(greeting.substring(0,3)=="Hel");//false
    }
}
标签:public stat package code pre ring out void 区分大小写
原文地址:https://www.cnblogs.com/xl4ng/p/12549253.html