2013-01-05 45 views
-1

可能重複:
How to convert number to words in java設置長值

我想設置的文本字段長值我的代碼修改爲如下錯誤是什麼表示需要長髮現INT

private void jTextField2MouseClicked(java.awt.event.MouseEvent evt) { 
     if(evt.getSource()==jTextField2){ 
      long jml = Long.parseLong(jTextField3.getText()); 

      jTextField1.setText(numberToWord(jml)); 

     } 
    } 
+0

我實際上更新了一些編碼部分並重新發布了它 –

回答

0

NumberFormatExceptionThrown to indicate that the application has attempted to convert a string to one of the numeric types, but that the string does not have the appropriate format.因此,例外可能是因爲java int的最大值是2,147,483,647(這是一個10位整數)。

0

錯誤是發生在下面一行,看起來就像你正在使用Integer.parseInt()方法在下面的線,

at myproj.Certificates.jTextField2MouseClicked(Certificates.java:268) 

當正在傳遞給方法Integer.parseInt()值大於Integer.MAX_VALUE更大(2,147,483,647 ),您將收到java.lang.NumberFormatException

而且由於10000000000大於2,147,483,647,您將得到NumberFormatException。

+1

所以使用long,Long.parseLong。 –

+0

long jml = Long.parseLong。(jTextField3.getText()); 我以上試過,但它顯示標識符預計錯誤 –

+0

那麼它現在工作? – Jayamohan