正在加载图片...
例5.1演示Java中异常的产生。 import javax.swing.JOptionPane; public class TestNumFormatException{ public static void main(String args[){ String s=JOptionPane.showInputDialog("请输入整数"); /创建文本输入对话框 System.out.print("转换字符串"+s+""为整数:"); intk=Integer.parseInt(s);/把字符串转化为整数 System.out.println(k);/打印输出 电裂 点击此处结柬放映 例5.1 演示Java中异常的产生。 i j i JO i P import javax.swing.JOptionPane; public class TestNumFormatException { publi t ti id i (St i []) { blic static void main(String args[]) { String s=JOptionPane.showInputDialog("请输入整数"); //创建文本输入对话框 System.out.print("转换字符串\""+s+"\"为整数:"); itk n =I t I t( ) Integer.parseInt(s);//把字符串转化为整数 把字符串转化为整数 System.out.println(k);//打印输出 } }
<<向上翻页向下翻页>>
©2008-现在 cucdc.com 高等教育资讯网 版权所有