Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

294
Views
Collections.emptyList() vs ImmutableList.of() de guayaba

El título lo dice todo. Es una pregunta simple en realidad. Solo quería entender cómo funcionan realmente estas dos cosas. ¿Cuál sería la mejor opción para devolver una lista vacía inmutable? ¿Sería mejor hacer Collections.emptyList() o ImmutableList.of() o hay una tercera y mejor opción?

over 4 years ago · Santiago Trujillo
1 answers
Answer question

0

Yo usaría Collections.emptyList() porque

1) ¿Por qué usar una biblioteca de terceros cuando ya tiene la misma en JDK?

2) Collections.emptyList() devuelve una Collections.EMPTY_LIST de clase privada realmente simple (ver Collections.java en JDK).

Mientras que ImmutableList.of() devuelve una lista inmutable de Guava con toda la funcionalidad como si realmente contuviera objetos, inicializándolo con el new Object[0] .

Si solo necesita la lista vacía, entonces no necesita la funcionalidad ImmutableList .

over 4 years ago · Santiago Trujillo Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!