Here I wrote a program that will print longest palindromic substring in a given string.. Here can you suggest me how to improve performance of this program..
void longestPalindrome(){
    String str = "malayalam";
    String pal = "";
    int c = 0;
    String arr[] = new String[100];
    for(int i=0;i<str.length();i++){
        for(int j=i;j<str.length();j++){
            if(str.charAt(i)==str.charAt(j)){
                pal = str.substring(i,j+1);
                if(pal.length()>2 && checkPalindrome(pal)){
                    System.out.println(pal);
                    arr[c] = pal;
                    c=c+1;
                }
                pal = "";
            }
        }
    }
    String newArray[] = new String[c];
    System.out.print("The Palindromes are!!-->>>");
    for(int k=0;k<c;k++){
        newArray[k] = arr[k];
        System.out.print(newArray[k]+",");
    }
    System.out.println();
    if(newArray.length>1){
    for(int i=0;i<newArray.length;i++){
        for(int j=i+1;j<newArray.length;j++)
            if(newArray[i].length() < newArray[j].length()){
                String temp = newArray[i];
                newArray[i] = newArray[j];
                newArray[j] = temp;
            }
    }
    }
    if(newArray.length>0)
        System.out.println("The LONGEST PALINDROME --- "+newArray[0]);
 
    