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

151
Views
Se puede reemplazar con la referencia del método usando la reflexión en Java

Tengo este código en intellij:

 return collection.stream().anyMatch(annotation -> method.isAnnotationPresent(annotation));

Y el compilador me dice que "method.isAnnotationPresent(annotation)" se puede reemplazar con la referencia del método y no sé cómo hacerlo porque tiene un argumento.

¿Alguien sabe cómo hacer eso?

over 4 years ago · Santiago Trujillo
1 answers
Answer question

0

Puede reemplazar su código para usar la referencia del método (consulte aquí ) como se muestra a continuación:

 return collection.stream().anyMatch(method::isAnnotationPresent);

Básicamente, está proporcionando la definición del método isAnnotationPresent() a la expresión Lambda (del método anyMatch que acepta Predicate ) y el valor de la secuencia se pasará automáticamente como argumento al método anyMatch .

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!