code: public static <T> T getLast(List<T> list)
      {
          if (list == null)
          {
              return null;
          }
          if (list instanceof RandomAccess)
          {
              return RandomAccessListIterate.getLast(list);
          }
          ListIterator<T> iterator = list.listIterator(list.size());
          if (iterator.hasPrevious())
          {
              return iterator.previous();
          }
          return null;
      }
docs: Returns the last element of a list.