http://blog.csdn.net/pipisorry/article/details/51050189
很久没写java,什么都不会了,小记一下。
类型转换
字符串转int类型:Integer.valueOf
double转字符串:
double a = 3.2133535;
String c = String.valueOf(a);
String a = new DecimalFormat("######0.00").format(a);
[java 四舍五入保留小数]
public static void main(String[] args) {
System.out.println("Integer.MIN_VALUE = " + Integer.MIN_VALUE);
System.out.println("Integer.MAX_VALUE = " + Integer.MAX_VALUE);
System.out.println("Long.MIN_VALUE = " + Long.MIN_VALUE);
System.out.println("Long.MAX_VALUE = " + Long.MAX_VALUE);
System.out.println("Float.MIN_VALUE = " + Float.MIN_VALUE);
System.out.println("Float.MIN_NORMAL = " + Float.MIN_NORMAL);
System.out.println("Float.MAX_VALUE = " + Float.MAX_VALUE);
System.out.println("Double.MAX_VALUE = " + Double.MAX_VALUE);
System.out.println("Double.MIN_VALUE = " + Double.MIN_VALUE);
}
switch(表达式){
case 常量表达式1:
语句1;
break;
default:
语句;
}
文件路径操作
路径合并:Path path = Paths.get("foo", "bar", "baz.txt");
String file = Paths.get(DIR, hdfs_filename).toString();
[Combine paths in Java]
java执行
windows下可以在java源文件所在文件夹建立一个记事本文档保存为"Java运行批处理.bat",输入以下3行代码
javac HelloWorld.java
java HelloWorld
@pause
然后双击将出现cmd窗口下的编译运行结果
出错:Error: Could not find or load main class
java HelloWorld.class将后面的class去掉就ok了
from: http://blog.csdn.net/pipisorry/article/details/51050189
ref: