我用下面的Java代码显示编译错误,请告知我该如何克服
public class Chaining {
import java.util.concurrent.CompletableFuture;
public class Chaining {
public static void main(String[] args) {
CompletableFuture.supplyAsync(() -> ThreadLocalRandom.current().nextInt(1, 10))// ** getting compilation error ***
.thenApply(Math::sqrt)
.thenAccept(System.out::println)
.join();
}
}
}
答案 0 :(得分:1)
应该是这样:
import java.util.concurrent.CompletableFuture;
import java.util.concurrent.ThreadLocalRandom;
public class Chaining {
public static void main(String[] args) {
CompletableFuture.supplyAsync(() -> ThreadLocalRandom.current().nextInt(1, 10))// ** getting compilation error ***
.thenApply(Math::sqrt)
.thenAccept(System.out::println)
.join();
}
}
请学习使用IDE的功能。