daily pastebin goal
4%
SHARE
TWEET

Untitled

a guest Dec 7th, 2017 53 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. public class SameEnds {
  2.    
  3.     public static void main (String args[]) {
  4.  
  5.         String test = "abXYab";
  6.         int testLength = test.length();
  7.         String longestSub = " ";
  8.  
  9.         for (int i = 0; i < (testLength / 2); i++) {
  10.             if (test.substring(i).equals(test.substring(testLength - i)))
  11.                 longestSub = test.substring(i);
  12.         }
  13.  
  14.         System.out.println(longestSub);
  15.  
  16.     }
  17.    
  18. }
RAW Paste Data
Top