上机执行下列程序( 学习·Runtime类),注意观察程序的输出结果。
public class Test{ public static void main(String args[]){ Runtime runtime=Runtime.getRuntime(); long free = runtime.freeMemory(); System.out,println("Java虚拟机可用空闲内存"+free+“bytes”); long total = runtime.totalMemory(); System.out.println("Java虚拟机占用总内存"+total+“bytes”); long n1 = System.currentTimeMillis(); for(){ int j=2; for(int i=1;i<=100;i++){ if(;j<=i/2;j++){ if(i%j==0)break; } if(j>1/2)System.out.print(" "+i); } long n2 = System.currentTimeMillis(); System.out,printf("\n循环用时:"+(n2-n1)+"毫秒\n"); free = runtime.freeMemory(); System.out.println("Java虚拟机可用空闲内存"+free+"bytes"); total = runtime.totalMemory(); System.out.println("Java虚拟机占用总内存 "+total+" bytes"); } }