Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

300
Vistas
Collections.emptyList() vs guava's ImmutableList.of()

The title says it all. It is a simple question really. Just wanted to understand how both these stuffs really work. Which would be the best option to return an immutable empty list? Would it be better to do Collections.emptyList() or ImmutableList.of() or is there a third and better option?

over 4 years ago · Santiago Trujillo
1 Respuestas
Responde la pregunta

0

I would use Collections.emptyList() because

1) why use a 3rd party library when you already have the same in JDK

2) Collections.emptyList() returns a real simple private class Collections.EMPTY_LIST (see Collections.java in JDK).

Whereas ImmutableList.of() returns a Guava immutable list with all the functionality as if really containing objects, initializing it with new Object[0].

If you only need the empty list then you do not need the ImmutableList functionality.

over 4 years ago · Santiago Trujillo Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda