double a = 12.236;                        
a = Math.round(a*Math.pow(10,2));    
a = a/Math.pow(10,2);                     
System.out.println(a);                    

解决方案 »

  1.   

    import java.math.*;class A{
    public static void main(String[] args){

    double a = 12.236;                        
    BigDecimal bd=new BigDecimal(a);                   
    System.out.println(bd.setScale(2,BigDecimal.ROUND_HALF_UP));  

    }
      

  2.   

    double a
    double b
     b=a*100+0.5
    a=round(b)/100
      

  3.   

    你仔细研究一下math包吧,那里可以帮你解决这个问题
      

  4.   

    double a = 12.236;                        
    a = Math.round(a*100);    
    a = a/100;                     
    System.out.println(a);