看板 java 關於我們 聯絡資訊
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)
No:在那頁教學範例中就有寫到,往上翻一下 06/09 00:20
No:當你在程式中寫下一個整數時,預設是使用不超過int型態的長度 06/09 00:22
No:我回文好了 不能連推 06/09 00:24