声明变量类型,常用的有哪几种?
我只知道 int , String
jdk里面也没看到告诉我可以用哪些关键字声明变量啊。
int i=0;
Integer j=0; //这句对不对?
问题点数:20、回复次数:9Top
1 楼hhygcy(小楼一夜听春雨)回复于 2004-12-03 09:57:19 得分 0
Integer j=0; //这句对不对?
Integer Boolean Byte Short Character Long 这些是用来把基本类型
int bool byte short char long数据类型转换成引用的
因为Collection只能和引用类型一起使用Top
2 楼xdhou(办公室坐久了,想晒晒太阳)回复于 2004-12-03 09:57:19 得分 1
学一下java就知道了。Top
3 楼xdhou(办公室坐久了,想晒晒太阳)回复于 2004-12-03 09:58:52 得分 0
学一下java就知道了。Top
4 楼skylan(君若为云,我愿为风,领君遨游宇宙中)回复于 2004-12-03 11:08:42 得分 4
char , long , Byte , short ,boolean 等等Top
5 楼guishuanglin(蓝色枫林)回复于 2004-12-03 11:31:57 得分 1
int String
这两个可以做任何开发了,Top
6 楼cuixiping(无心●愚公)回复于 2004-12-03 16:36:28 得分 0
还有一些,比如 浮点数,单精度,双精度,是怎么声明的呢?
还有表示 日期时间的,是怎么声明的呢?
(刚学,大家不要笑我问的这么弱智)Top
7 楼catblue(佛家说:一粒沙中看世界。)回复于 2004-12-03 17:06:42 得分 8
Integer j=0;不对
应该Integer j= new Integer("1");
char , long , byte , short ,boolean ,float ,double ,int 这些是基本类型
hhygcy(小楼一夜听春雨) 说的也不少了,看看。
日期格式
private static SimpleDateFormat formatter =
new SimpleDateFormat("yyyyMMdd");
private static SimpleDateFormat longFormatter =
new SimpleDateFormat ("yyyyMMddHHmmss");
private static SimpleDateFormat timeStampFormatter =
new SimpleDateFormat ("yyyy-MM-dd HH:mm:ss");
得到日期:
SimpleDateFormat formatter=new SimpleDateFormat("yyyy-MM-dd");
String time=formatter.format(new Date());//得到当前时间Top
8 楼chubbchubb(长街)回复于 2004-12-03 17:08:58 得分 6
//单精度浮点数
float f = 12.12f;
//双精度
double d = 12.003D;
//日期时间
Date date = new Date();Top
9 楼cuixiping(无心●愚公)回复于 2004-12-04 22:52:26 得分 0
真是谢谢大家了!
解了我不是迷惑。
我正在看java基础的书。Top




