看java大学教程(java how to program)或者java程序设计教程(programming with java)

解决方案 »

  1.   

    你的第二个程序的input变量定义在循环里面,要报错,作用域不同
      

  2.   

    Double  a=3.6;和Double a=new Double(3.6);
    好像 Double a=3.6是不允许的表达式吧。
      

  3.   

    import javax.swing.*;
    public class toTestInteger
    {     public static void main(String args[])
          
          {      String input=null;
                try{ do
                 {       input=JOptionPane.showInputDialog    //
                                       ("Please enter a number:");
                         int     convertedInput=Integer.parseInt(input);
                         String  inputInBase2=Integer.toBinaryString(convertedInput);
                         System.out.println(inputInBase2);
                         System.out.println(Integer.toString(convertedInput));
                         System.out.println(Integer.toHexString(convertedInput));
                         System.out.println(Integer.toOctalString(convertedInput));
                         input=JOptionPane.showInputDialog
                               ("Do you want to exit?(Y/N)");
                         input=input.toUpperCase( );
                 }
                 while(input.equals("N"));
                }catch(NumberFormatException e){}
                 System.exit(0);
          }

    Double  a=3.6;是变量初始化,Double a=new Double(3.6);是创建了一个对象a,值为3.6