Print the middle character of a string | Java program for the above approach ; Function that prints the middle character of a string ; Finding string length ; Finding middle index of string ; Print the middle character of the string ; Driver Code ; Given string str ; Function Call
class GFG { public static void printMiddleCharacter ( String str ) { int len = str . length ( ) ; int middle = len / 2 ; System . out . println ( str . charAt ( middle ) ) ; } public static void main ( String args [ ] ) { String str = " GeeksForGeeks " ; printMiddleCharacter ( str ) ; } }