私はちょうどJavaでそれを行う方法を整数として10をしたい「10.000」のような文字列がありますか?

何:

私はちょうどJavaでそれを行う方法を整数として10をしたい「10.000」のような文字列がありますか?

私が持っているdone`

public static final Comparator<Product> By_PRICE  = new Comparator<Product>() {
       @Override
       public int compare(Product o1, Product o2) {
           //for name
//           return o1.getName().compareTo(o2.getName());

//           return o1.getFinalPrice().compareTo(o2.getFinalPrice());


           return Integer.parseInt(o1.getFinalPrice()) > Integer.parseInt(o1.getFinalPrice()) ? -1
                   : (Integer.parseInt(o1.getFinalPrice()) < Integer.parseInt(o1.getFinalPrice())) ? 1 : 0;




//           if (o1.getFinalPrice().compareTo(o2.getFinalPrice())>0){
//               return 1;
//           }
//           else if (o1.getFinalPrice().compareTo(o2.getFinalPrice())<0){
//               return -1;
//           }
//           else {
//               return 0;
//           }

       }
   };

`このように私は私がそれに切り替えた場合、私のrecyclerviewのためにそれを使用したい、私はほとんどすべてを試みたが、私はスイッチ場合、スイッチその後、昇順にしている場合、それをソートする答えを見つけることができない文字列としてJSONから取得しています私のデータをソートしますその後、降順オフ

Snbgsw:

あたりとしてhttps://docs.oracle.com/javase/7/docs/api/java/lang/Math.html#round(float) )(使用恐らくMath.round

System.out.println(Math.round(Float.valueOf("10.000")))

おすすめ

転載: http://43.154.161.224:23101/article/api/json?id=223843&siteId=1