gpt4 book ai didi

java - 为什么我得到 "the receiver expression should be replaced with the type qualifier"?

转载 作者:太空宇宙 更新时间:2023-11-04 09:43:43 24 4
gpt4 key购买 nike

$ javac Main.java 
Main.java:27: error: illegal static interface method call
ProcessHandle.current().allProcesses().mapToLong(w->w.pid()).forEach(System.out::println);
^
the receiver expression should be replaced with the type qualifier 'ProcessHandle'
1 error

为什么我收到“接收者表达式应替换为类型限定符‘ProcessHandle’”?

我该怎么办?谢谢。

<小时/>
import java.lang.System;
import java.io.File;
import java.io.IOException;
import java.util.stream.Stream;

public class Main {

public static void main(String args[]){

System.out.println("visible processes pids are: ");
ProcessHandle.current().allProcesses().mapToLong(w->w.pid()).forEach(System.out::println);

}
}

最佳答案

您想在这里实现什么目标?询问当前的 ProcessHandle 然后使用它来查询 allProcesses 似乎没有多大意义。这两个都是静态方法。您可能只想省略“.current()”。

关于java - 为什么我得到 "the receiver expression should be replaced with the type qualifier"?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/55669096/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com