Advertisement
Guest User

Bad way

a guest
Nov 24th, 2017
54
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.58 KB | None | 0 0
  1. public class Test {
  2.  
  3.     public static void main(String[] args) {
  4.         assertEqual("TestDit", parse("getTestDit"));
  5.         assertEqual("TestDit", parse("TestDit"));
  6.         assertEqual("", parse("get"));
  7.  
  8.         System.out.println("done");
  9.     }
  10.  
  11.     private static void assertEqual(String expected, String actual) {
  12.         if (!expected.equals(actual)) {
  13.             throw new AssertionError("Expected [" + expected + "] got [" + actual + "]");
  14.         }
  15.     }
  16.  
  17.     public static String parse(String input) {
  18.         return input.replaceAll("^get", "");
  19.     }
  20. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement