2022-01-04 星期二 1024 by:enAn
随手笔记
java的基本类型,必需定义并且初始化才能使用
import java.text.SimpleDateFormat;
import java.util.Date;
/**
* @author:
* @date:2022-01-04
* @desc
* Variable 'dataInt' might not have been initialized
* Variable 'data_String' might not have been initialized
* Variable 'data_double' might not have been initialized
* Variable 'data_float' might not have been initialized
*/
public class AAAA {
public static void main(String[] args) {
int dataInt = 0;
String data_String = null;
double data_double = 0 ;
float data_float = 0;
StringBuffer bf = new StringBuffer();
String dateStr = new SimpleDateFormat("YYYY-MM-dd HH:MM:ss").format(new Date());
bf.append(String.format("[日期:%s]:",dateStr));
bf.append("必需初始化再使用-否则编辑报错:");
bf.append(String.format("默认-int:%s,",dataInt));
bf.append(String.format("默认-String:%s,",data_String));
bf.append(String.format("默认-double:%s,",data_double));
bf.append(String.format("默认-float:%s",data_float));
System.out.println(bf.toString());
// [日期:2022-01-04 10:01:56]:必需初始化再使用-否则编辑报错:默认-int:0,默认-String:null,默认-double:0.0,默认-float:0.0
}
}