Forget String.subString()

When ever you have to extract some chars from string then you se String.subString() method but apache has given org.apache.commons.lang3.StringUtils  class which is much better than string suppose when you have a string “aabbccddefghdz” and you want all chars that  comes after last occurence of d then you should use

System.out.println(StringUtils.substringAfterLast(“aabbccddefghdzac”, “d”));

so the result will be zac.

There are many more methods in StringUtils which you should use rather than string if you want to make performance good

Published by nareshjavatips

Java Edicted

Leave a comment