Consider the following code:
ArrayList<Integer> aList = new ArrayList<Integer>(); aList.add(2134); aList.add(3423); aList.add(4234); aList.add(343); String tmpString = "("; for(int aValue : aList) { tmpString += aValue + ","; } tmpString = (String) tmpString.subSequence(0, tmpString.length()-1) + ")"; System.out.println(tmpString);
My result is here (2134.3423.4234.343), as expected.
I replace the last comma with the ending) to get the expected result. Is there a better way to do this overall?
java string
StefanE
source share