Java String equals() 方法示例.


Java String equals() 方法示例.

import java.lang.*;

public class StringDemo {

   public static void main(String[] args) {

      String str1 = new String("sachin tendulkar");

      String str2 = new String("amrood admin");

      String str3 = new String("amrood admin");



      // checking for equality

      boolean retval1 = str2.equals(str1);

      boolean retval2 = str2.equals(str3);



      // prints the return value

      System.out.println("str2 is equal to str1 = " + retval1);

      System.out.println("str2 is equal to str3 = " + retval2);

   }

}