有 Java 编程相关的问题?

你可以在下面搜索框中键入要查询的问题!


共 (4) 个答案

  1. # 1 楼答案

    你所说的“输出”是什么意思?它是否将字符串打印到控制台

    假设您有以下情况:

    String s = ...; // Something that creates bbccaa
    System.out.println(s);
    

    然后你可以做:

    s.equals(otherString);
    

    比较两个字符串

  2. # 2 楼答案

    怎么样

    "bbccaa".equals(anotherString)
    

    "bbccaa".compareTo(anotherString)
    

  3. # 3 楼答案

    使用equalsIgnoreCase()equals()比较两个字符串对象

    String s = "hello";
    
    String sOutput = "bbccaa";
    
    if (sOutput.equalsIgnoreCase(s)){   // Ignore case while comparing
    
    
     }
    
    
    if (sOutput.equals(s)){            // Consider case while comparing
    
    
     }
    
  4. # 4 楼答案

    这个字符串是如何生成的? 如果使用流,则将流保存为字符串并使用equals方法