Advertisement
makispaiktis

23. String methods

May 31st, 2022 (edited)
249
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.50 KB | None | 0 0
  1. import java.util.Locale;
  2.  
  3. public class myClass {
  4.  
  5.     // MAIN FUNCTION
  6.     public static void main(String[] args){
  7.         String a = "Apples";
  8.         String b = "bucky";
  9.         String c = "BUCKY";
  10.         System.out.println(a.length());
  11.  
  12.         // Compare strings (not "==" ---> by reference)
  13.         if(a.equals("Apples")){
  14.             System.out.println("Yes! " + a);
  15.         }
  16.         if(b.equalsIgnoreCase(c)){
  17.             System.out.println("Match! equalsIgnoreCase");
  18.         }
  19.     }
  20. }
  21.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement