阿波罗的战车
我最初提供了此示例(链接到威廉·布伦德尔对另一个主题的答案)。该主题的创建者(Steve M)想要创建一个多平台的Java应用程序。具体地说,用户试图找到一种方法来评估运行中的计算机的资源(磁盘空间,CPU和内存使用情况)。这是该主题给出的答案的内联成绩单。但是,尽管我的回答被标记为已接受,但在该主题上已指出这不是理想的解决方案。public class Main { public static void main(String[] args) { /* Total number of processors or cores available to the JVM */ System.out.println("Available processors (cores): " + Runtime.getRuntime().availableProcessors()); /* Total amount of free memory available to the JVM */ System.out.println("Free memory (bytes): " + Runtime.getRuntime().freeMemory()); /* This will return Long.MAX_VALUE if there is no preset limit */ long maxMemory = Runtime.getRuntime().maxMemory(); /* Maximum amount of memory the JVM will attempt to use */ System.out.println(&#