how to print the first and last letter of a string in java with substirng code example
Example 1: java get first char
char fourth = "Banana".charAt(3);
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));
}
}