// Array of names
String name [] = {"Clark", "Bruce", "Diana", "Barry"};
// for each loop (to iterate everything inside the array)
for (String names: name) {
System.out.println(names.charAt(0));
}
/* Prints
C
B
D
B
*/
public String firstElement(String[] array)
{
if (array.length >= 1)
{
return array[0];
}
else {
return "";
}
}