[請問] 一條爪哇問題

看板java作者 ( 嗨浪)時間14年前 (2011/06/08 22:37), 編輯推噓2(201)
留言3則, 1人參與, 最新討論串1/3 (看更多)
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)

06/09 00:20, , 1F
在那頁教學範例中就有寫到,往上翻一下
06/09 00:20, 1F

06/09 00:22, , 2F
當你在程式中寫下一個整數時,預設是使用不超過int型態的長度
06/09 00:22, 2F

06/09 00:24, , 3F
我回文好了 不能連推
06/09 00:24, 3F
文章代碼(AID): #1DxuaCD3 (java)
文章代碼(AID): #1DxuaCD3 (java)