System:
全是静态的成员,不能实例化。
//演示System。获取当前时间。
package cn.itcast.p7.other;
import java.util.Iterator;
import java.util.Properties;
import java.util.Set;
public class SystemDemo {
private static final String LINE_SEPARATOR = System.getProperty("line.separator");
public static void main(String[] args) {
long time= System.currentTimeMillis();
//System.out.println(time);//1364114590000
Properties prop = System.getProperties();
//获取系统的属性信息。
//Set<String> keySet = prop.stringPropertyNames();
//
//Iterator<String> it = keySet.iterator();
//while(it.hasNext()){
//String key = it.next();
//String value = prop.getProperty(key);
//System.out.println(key+"::"+value);
//}
//通过指定键获取值。
//String osName = System.getProperty("os.name");
//System.out.println(osName);
//通过System.getProperty("line.separator")就可以实现在任何操作系统,都可以换行。
//因为System.getProperty("line.separator")是获取与系统平台有关的行分隔符。
System.out.println("hello"+LINE_SEPARATOR+"world");
}
}
转载于:https://blog.51cto.com/pengya123/1786363