Advertisement
Guest User

Untitled

a guest
Apr 23rd, 2014
42
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.87 KB | None | 0 0
  1. "Hiabc", "abc" -> true
  2. "AbC", "HiaBc" -> true
  3. "abc", "abXabc" -> true
  4. "abc", "abXaXc" -> false
  5.  
  6. String str1Lower = str1.toLowerCase();
  7. String str2Lower = str2.toLowerCase();
  8. if (str1Lower.endsWith(str2Lower) || str2Lower.endsWith(str2Lower) {
  9. System.out.println ("One of the strings is the end of the other");
  10. } else {
  11. System.out.println ("bummer.");
  12. }
  13.  
  14. public static void main(String[] args) {
  15. // TODO Auto-generated method stub
  16.  
  17. String s1="abc";
  18. String s2="zzzABC";
  19.  
  20. s1 = s1.toUpperCase(); //remember string immutable so have to assign once again
  21. s2 = s2.toUpperCase();
  22.  
  23. if(s1.endsWith(s2) || s2.endsWith(s1))
  24. System.out.println("one of the string appears at the very end of others");
  25.  
  26. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement