Here you can find the source of ZeroRemover(String[] a)
public static String[] ZeroRemover(String[] a)
//package com.java2s; //License from project: Open Source License public class Main { public static String[] ZeroRemover(String[] a) { if (NeedRemove(a)) { for (int i = 0; i < a.length; i++) { String aString = a[i]; aString = aString.substring(0, aString.length() - 1); if (aString.endsWith(".")) aString = aString.substring(0, aString.length() - 1); a[i] = aString;/*from w ww .j a va 2s.c o m*/ } } else return a; // second pass if (NeedRemove(a)) { for (int i = 0; i < a.length; i++) { String aString = a[i]; aString = aString.substring(0, aString.length() - 1); if (aString.endsWith(".")) aString = aString.substring(0, aString.length() - 1); a[i] = aString; } } else return a; // 3rd pass if (NeedRemove(a)) { for (int i = 0; i < a.length; i++) { String aString = a[i]; aString = aString.substring(0, aString.length() - 1); if (aString.endsWith(".")) aString = aString.substring(0, aString.length() - 1); a[i] = aString; } } else return a; return a; } /** * Determin: should 0 be remove? * @return formatted string */ public static boolean NeedRemove(String[] a) { int kk = 0; for (int i = 0; i < a.length; i++) { if (a[i].indexOf(".") > -1 && a[i].endsWith("0")) kk++; } if (kk == a.length) return true; return false; } }