“Bandingkan dua string java” Kode Jawaban

di Java bagaimana membandingkan dua string

class scratch{
    public static void main(String[] args) {
        String str1 = "Nyello";
        String str2 = "Hello";
        String str3 = "Hello";

        System.out.println( str1.equals(str2) ); //prints false
        System.out.println( str2.equals(str3) ); //prints true
    }
}
Nitbit25

Bandingkan dua string java

class Main {
  public static void main(String[] args) {

    // create 3 strings
    String first = "java programming";
    String second = "java programming";
    String third = "python programming";

    // compare first and second strings
    boolean result1 = first.equals(second);
    System.out.println("Strings first and second are equal: " + result1);

    // compare first and third strings
    boolean result2 = first.equals(third);
    System.out.println("Strings first and third are equal: " + result2);
  }
}
SAMER SAEID

Jawaban yang mirip dengan “Bandingkan dua string java”

Pertanyaan yang mirip dengan “Bandingkan dua string java”

Jelajahi jawaban kode populer menurut bahasa

Jelajahi bahasa kode lainnya