How to get first element from iterable object ?

We can do that with...first() method. It allows to not only get the first element but also to get a default object when iterable object is empty:

@Test
public void should_get_first_element() {
  String firstLetter = FluentIterable.of(new String[] {"A", "B", "C", "D", "E"})
    .first().or("DEFAULT");

  assertThat(firstLetter).isEqualTo("A");
}

@Test
public void should_get_default_from_empty_iterable() {
  String firstLetter = FluentIterable.of(new String[] {})
    .first().or("DEFAULT");

  assertThat(firstLetter).isEqualTo("DEFAULT");
}

@Test
public void should_get_first_value_from_iterables() {
  List<String> letters = Lists.newArrayList("A", "B", "C", "D", "E");
  String firstLetter = Iterables.getFirst(letters, "DEFAULT");

  assertThat(firstLetter).isEqualTo("A");
}

@Test
public void should_get_default_value_from_iterables() {
  String firstLetter = Iterables.getFirst(Collections.emptyList(), "DEFAULT");

  assertThat(firstLetter).isEqualTo("DEFAULT");
}