当前位置: 技术问答>java相关
我的第一个JAVA程序(THINGING IN JAVA书上的)怎么调不通?解决即结帖.
来源: 互联网 发布时间:2015-09-12
本文导语: //程序是这样的 //Property.java import java.util.*; public class Property { public static void main(String[] args) {System.out.println (new Data()); Properties p = System.getProperties(); p.list(System.out); System.out.println("---Memory ...
//程序是这样的
//Property.java
import java.util.*;
public class Property
{
public static void main(String[] args)
{System.out.println (new Data());
Properties p = System.getProperties();
p.list(System.out);
System.out.println("---Memory Usage:");
Runtime rt = Runtime.getRuntime();
System.out.println("Total Memory = "
+ rt.totalMemory()
+ "Free Memory = "
+ rt.freeMempry());
}
//Property.java
import java.util.*;
public class Property
{
public static void main(String[] args)
{System.out.println (new Data());
Properties p = System.getProperties();
p.list(System.out);
System.out.println("---Memory Usage:");
Runtime rt = Runtime.getRuntime();
System.out.println("Total Memory = "
+ rt.totalMemory()
+ "Free Memory = "
+ rt.freeMempry());
}
|
只有两处拼写错误:
import java.util.*;
public class Property
{
public static void main(String[] args)
{System.out.println (new Date());
//-----------
Properties p = System.getProperties();
p.list(System.out);
System.out.println("---Memory Usage:");
Runtime rt = Runtime.getRuntime();
System.out.println("Total Memory = "
+ rt.totalMemory()
+ "Free Memory = "
+ rt.freeMemory());
//-----------
}
import java.util.*;
public class Property
{
public static void main(String[] args)
{System.out.println (new Date());
//-----------
Properties p = System.getProperties();
p.list(System.out);
System.out.println("---Memory Usage:");
Runtime rt = Runtime.getRuntime();
System.out.println("Total Memory = "
+ rt.totalMemory()
+ "Free Memory = "
+ rt.freeMemory());
//-----------
}
|
new Data();错了
是new Date()
是new Date()
|
//程序是这样的
//Property.java
import java.util.*;
public class Property
{
public static void main(String args[])
{
System.out.println (new Date());
//-----------
Properties p = System.getProperties();
p.list(System.out);
System.out.println("---Memory Usage:");
Runtime rt = Runtime.getRuntime();
System.out.println("Total Memory = "
+ rt.totalMemory()
+ "Free Memory = "
+ rt.freeMemory());
//-----------
}
}
//Property.java
import java.util.*;
public class Property
{
public static void main(String args[])
{
System.out.println (new Date());
//-----------
Properties p = System.getProperties();
p.list(System.out);
System.out.println("---Memory Usage:");
Runtime rt = Runtime.getRuntime();
System.out.println("Total Memory = "
+ rt.totalMemory()
+ "Free Memory = "
+ rt.freeMemory());
//-----------
}
}
|
文件名必须与声明为public的类名相同。也就是说,文件名必须为Property.java。
不是两条注释语句的问题,你好好看看,注释出来的两处与你原来写的是一样的吗?:)
不是两条注释语句的问题,你好好看看,注释出来的两处与你原来写的是一样的吗?:)
|
namowen(寒号不已) 得分了~!同意他的意见~!
|
建议用Textpad文本器试
CLASSPATH 是否设好?
CLASSPATH 是否设好?