Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public class Remove {
- public static String trimPoints(String txt)
- {
- long start = System.currentTimeMillis();
- char[] cs = txt.toCharArray();
- int index =0;
- for(int x =cs.length-1;x>=0;x--)
- {
- if(cs[x]=='.')
- continue;
- else
- {
- index = x+1;
- break;
- }
- }
- String response = txt.substring(0,index);
- System.out.println("fun took: "+(System.currentTimeMillis()-start));
- return response ;
- }
- public static void main(String args[])
- {
- System.out.println(trimPoints("abc....."));
- long start = System.currentTimeMillis();
- String fi = "abc.....".replaceAll("\\.+$", "");
- System.out.println("regex took: "+(System.currentTimeMillis()-start));
- System.out.println(fi);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement