how to return the first character in an array from a method java

Java
public String firstElement(String[] array)
{
      if (array.length >= 1)
      {
      return array[0];
      }
      else {
          return "";
      }
}var string = "freeCodecamp";

string.charAt(0); // Returns "f"
Source

Also in Java: