Q:

Having trouble with Java exercise for University (Strings)

Given two strings, print true if either of the strings appears at the very end of the other string, ignoring upper/lower case differences (in other words, the computation should not be "case sensitive").
OK so I have established that I need to allow the input of 2 strings. Then I assume i need an if/else statement, where the if checks both strings to see whether or not the characters of the other string occur at the end of that string using IgnoreCase. If either string has the characters of the other string at the end, print true
and then else, print false.
I know how to input the two strings, and implement an if else statement, my problem is, how do I scan a string to see if it contains the contents of another string? and how do I specify that it has to be found at the end of the string. IE. 
"Hiabc", "abc" -> true                                                  
"AbC", "HiaBc" -> true                                                  
"abc", "abXabc" -> true                                                 
"abc", "abXaXc" -> false 

I have checked many online tutorials to try and find syntax that does this, however I cannot seem to find any.

A:

Not sure if you're allowed to use these builtin methods, but the easiest thing to do would be to call String.endsWith(String). Unfortunately, they don't have a case-insensitive variant, so just convert both strings to lower case (or upper case, same-same). E.g.:
String str1Lower = str1.toLowerCase(); 
String str2Lower = str2.toLowerCase();
if (str1Lower.endsWith(str2Lower) || str2Lower.endsWith(str2Lower) {
    System.out.println ("One of the strings is the end of the other");
} else {
    System.out.println ("bummer.");
}

