Answer the question
In order to leave comments, you need to log in
How to rewrite code from kotlin to java?
Please help me to rewrite this code in Java, I can still somehow get the usual code from Kotlin to Java, but I'm confused with lambdas
consumer.consume(Consumer { record -> println("Got key "
+ record.key()).toString() +
" val " +
record.value().toString() })
fun consume(recordConsumer: Consumer<ConsumerRecord<String, String>>) {
thread {
while (true) {
val records = consumer.poll(Duration.ofSeconds(1))
records.forEach{record -> recordConsumer.accept(record)}
}
}
}
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question