作者badbadook ( 嗨浪)
看板java
标题[请问] 一条爪哇问题
时间Wed Jun 8 22:36:59 2011
public static void main(String[] args) throws Exception {
DateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd");
Date birth = dateFormat.parse("1966-08-08");
Date current = new Date();
long life = current.getTime() - birth.getTime();
System.out.println("你今年的岁数为:" + (life / (365 * 24 * 60 * 60
* 1000))); }}
为何岁数爆掉是因为?
public class Main { public static void main(String[] args) {
System.out.println(Integer.MIN_VALUE == -Integer.MIN_VALUE); }}
为何为true阿 不是没有用""括起来 不是同一物件
--
※ 发信站: 批踢踢实业坊(ptt.cc)
◆ From: 118.168.243.189
※ 编辑: badbadook 来自: 118.168.243.189 (06/08 22:28)
※ 编辑: badbadook 来自: 118.168.243.189 (06/08 23:37)
1F:推 No:在那页教学范例中就有写到,往上翻一下 06/09 00:20
2F:→ No:当你在程式中写下一个整数时,预设是使用不超过int型态的长度 06/09 00:22
3F:推 No:我回文好了 不能连推 06/09 00:24