checking last 4 character of string java
Get last 4 characters
String input = "123456789"; //input string
String lastFourDigits = ""; //substring containing last 4 characters
if (input.length() > 4)
{
lastFourDigits = input.substring(input.length() - 4);
}
else
{
lastFourDigits = input;
}
System.out.println(lastFourDigits);