2008+08=200808

lili1 2008-12-04 07:52:48
Integer year=2008;
Integer month=8;

怎么得到字符串"200808"。
...全文
481 36 打赏 收藏 转发到动态 举报
写回复
用AI写文章
36 条回复
切换为时间正序
请发表友善的回复…
发表回复
caiming250 2008-12-15
  • 打赏
  • 举报
回复
DavisCaiMark Test
xql80329 2008-12-15
  • 打赏
  • 举报
回复
写个判断了事算了
mudumu 2008-12-15
  • 打赏
  • 举报
回复
year+""+new DecimalFormat("00").format(month.intValue());
简单明了,佩服!
zeusmc 2008-12-15
  • 打赏
  • 举报
回复
要强制转换的。
要不然都当成字符串相加了。
javaxiaobai 2008-12-15
  • 打赏
  • 举报
回复
[Quote=引用 35 楼 lingxixiaopang 的回复:]
Java codepublic class Test {

public static void main(String[] args) {

Integer year=2008;
Integer month=8;
Integer result = year*100+month;
System.out.println(result);
}
}
[/Quote]
这个也好用
dashi99 2008-12-15
  • 打赏
  • 举报
回复
路过看看
lingxixiaopang 2008-12-15
  • 打赏
  • 举报
回复
public class Test {

public static void main(String[] args) {

Integer year=2008;
Integer month=8;
Integer result = year*100+month;
System.out.println(result);
}
}
ZiSheng 2008-12-15
  • 打赏
  • 举报
回复
[Quote=引用 4 楼 Landor2004 的回复:]
引用 1 楼 AWUSOFT 的回复:
year+""+new DecimalFormat("00").format(month.intValue());

支持!
[/Quote]
支持一下
ZiSheng 2008-12-15
  • 打赏
  • 举报
回复
[Quote=引用 4 楼 Landor2004 的回复:]
引用 1 楼 AWUSOFT 的回复:
year+""+new DecimalFormat("00").format(month.intValue());

支持!
[/Quote]
支持一下
XiaPiaoXue 2008-12-15
  • 打赏
  • 举报
回复
强制类型转换
Integer t1=2008;
Integer t2=8;
String str1=t1.toString();
String str2=t2.toString();
String str=str1+str2;
支持
weishangzheng 2008-12-15
  • 打赏
  • 举报
回复

Integer year=2008;
Integer month=8;
String str1=year.toString();
String str2=month.toString();
System.out.println(str1+str2);
非典型射手 2008-12-15
  • 打赏
  • 举报
回复
[Quote=引用 8 楼 bao110908 的回复:]
String str = String.valueOf(year * 100 + month);
[/Quote]

perfect
KingZChina 2008-12-15
  • 打赏
  • 举报
回复
路过
cuijie_cn 2008-12-15
  • 打赏
  • 举报
回复
1楼已经给出正解 :)
amo_njupt 2008-12-13
  • 打赏
  • 举报
回复
[Quote=引用 19 楼 haoren_a 的回复:]
方法有很多,例如:
Integer year=2008;
Integer month=8;
String str=year+""+new DecimalFormat("00").format(month.intValue());
System.out.println(str);
这种是比较快一些得,而且我个人觉得比较好
[/Quote]
同意
myjava_024 2008-12-13
  • 打赏
  • 举报
回复
[Quote=引用 3 楼 wangming402407250 的回复:]
public class Q1
{
public static void main(String args[])
{
Integer t1=2008;
Integer t2=8;
String str1=t1.toString();
String str2=t2.toString();
String str=str1+str2;
System.out.println(str);
}
}
[/Quote]
解决了
haoren_a 2008-12-13
  • 打赏
  • 举报
回复
方法有很多,例如:
Integer year=2008;
Integer month=8;
String str=year+""+new DecimalFormat("00").format(month.intValue());
System.out.println(str);
这种是比较快一些得,而且我个人觉得比较好
ahlon 2008-12-07
  • 打赏
  • 举报
回复
[Quote=引用 1 楼 AWUSOFT 的回复:]
year+""+new DecimalFormat("00").format(month.intValue());
[/Quote]

正解
nulang 2008-12-07
  • 打赏
  • 举报
回复
.......................
nftdxnftdx 2008-12-05
  • 打赏
  • 举报
回复
public static void p(String s){
System.out.println(s);
}
public static void main(String[] args){

Integer year=2008;
Integer month=8;
String s = year+""+new DecimalFormat("00").format(month.intValue());
p(s);
}
加载更多回复(15)

62,614

社区成员

发帖
与我相关
我的任务
社区描述
Java 2 Standard Edition
社区管理员
  • Java SE
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧