Consider a word hello in your string. You can get the word length easily with word.length() this will return 5 for "Hello"
With another method called charAt(int position) you can get the character at the given position.
System.out.println(String.valueOf(word.charAt(0))); //The result is H
System.out.println(String.valueOf(word.charAt(4))); //The result is o
4 is the length of word minus one so try finding it dynamically for all the word this way:
String.valueOf((word.length()-1))
If you had two string you can compare them with:
string1.equals(string2)
this will return true if they are the same and false if they are not.
Below is the full source code:
String word = "Hello";
//no if is needed for the first one
println(word + " ends with letter " + word.charAt(word.length()-1) + ".");
if (String.valueOf(word.charAt(0)).equals(String.valueOf(word.charAt(word.length()-1)))) {
println(word + " starts and ends with the same letter.");
}