代码如下:
import javax.swing.JOptionPane;
public class Hex{
public static void main(String args[]){
String binary;
int a;
binary=JOptionPane.showIntputDialog("Enter first integer");
a=Integer.parseInt(binary);
int two=Interger.parseInt(temp,2);
JOptionPane.showMessageDialog(null,"the number is"+two,"Results",JOptionPane.PLAIN_MESSAGE);
System.exit(0);
}
}
报错截图:
import javax.swing.JOptionPane;
public class Hex{
public static void main(String args[]){
String binary;
int a;
//关键词错误 原文是 showIntputDialog 正常应该是showInputDialog showIn 后面多了一个t
binary=JOptionPane.showInputDialog("Enter first integer");
a=Integer.parseInt(binary);
//关键词错误 原文是 Interger 正常应该是 Integer 多了一个r
//声明错误 上面没有定义temp 在下面进行了引用
int two=Integer.parseInt(binary,2);
JOptionPane.showMessageDialog(null,"the number is"+two,"Results",JOptionPane.PLAIN_MESSAGE);
System.exit(0);
}
}