哈哈,终于看到一个我知道的问题了double x = 7.7;
int y = (int)Math.round(x);

解决方案 »

  1.   

    调用静态方法
    import java.lang.Math;;public class Tea
    {
      public static void main(String[]args)
      {
        double ss=12.2132;
        long a=Math.round(ss);
        float s=12;
        int b=Math.round(s);
      }
    }
      

  2.   

    楼上的:调用静态方法
    import java.lang.Math;;public class Tea
    {
      public static void main(String[]args)
      {
        double ss=12.2132;
        long a=Math.round(ss);
        float s=12;
        int b=Math.round(s);
      }
    }好像不太对
      

  3.   

    错了:)
    反了取整 / 求余 %public class test{
    public static void main(String[] args){
    int i =12345;
    int j = i/4;
    int k = i % 4;
    System.out.println(i);
    System.out.println(j);
    System.out.println(k);
    }
    }
      

  4.   

    求证一下概念:取整是去掉小数位吗? 比如:7.7 --->  7        -5.5 ---> -5  
    我懂得很少,请大家指教!
    问题太初级了,不好意思,  :)
      

  5.   

    public class Tea
    {
      public static void main(String[]args)
      {
        double ss=12.0132;
        long a= (long) ss;
        float s=12;
        int b=(int) s;
        System.out.println(a);
        System.out.println(b);
      }
    }
      

  6.   

    取整是去掉小数位
    Math.round()方法
    要是不行就自己写一个方法。比如:
    public int Round(double input){
        int output=0;
        for( ;input-1;input>=0){
            output++;
            }
        return output
    }
    //效率么就不敢保证了 啊哈哈哈~~~~~~~