how to get the last 4 character from a string code example
Example 1: java get last char of string
public class Test {
public static void main(String args[]) {
String string = args[0];
System.out.println("last character: " +
string.substring(string.length() - 1));
}
}
Example 2: last char in string java
public class Test {
public static void main(String args[]) {
String string = args[0];
System.out.println("last character: " +
string.substring(string.length() - 1));
}
}
Example 3: Complete the function to return the last X number of characters in the given string
def getLast(mystring, x):
y=len(mystring) - x #finding index from where the string needs to be printed
for i in range(y,(len(mystring))): # printing from y index to end of string
print(mystring[i],end="")
getLast('WGU College of IT', 13)