Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public class SameEnds {
- public static void main (String args[]) {
- String test = "abXYab";
- int testLength = test.length();
- String longestSub = " ";
- for (int i = 0; i < (testLength / 2); i++) {
- if (test.substring(i).equals(test.substring(testLength - i)))
- longestSub = test.substring(i);
- }
- System.out.println(longestSub);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement