The most basic form would be picking up the size:
x.substring(x.length() - 3);
The only problem is whether the string is less than 3, then you’d have to check it first. If you’re going to use it this way, it’s simpler than using a library. If you want to do the treatment I advise creating a function, so:
class Program {
    public static void main (String[] args) {
        System.out.println(Right("OlaMundo", 3));
    }
    public static String Right(String text, int length) {
        if (text.length() <= length) return null;
        return text.substring(text.length() - length);
    }
}
Behold working in the ideone. And in the repl it.. Also put on the Github for future reference.
							
							
						 
String size is always determinable by the method
length()– ramaral
For tag you should read this: https://answall.com/q/101691/101. Your question is about Java and you did not have the tag. It wasn’t about Android Studio.
– Maniero