13 July, 2019

Find all palindrome strings in a java array.


In this article, we will see how to find all palindrome strings from an array. This is a very frequently asked questions in interview.  Also there is a question to find all palindrome number from an array.  Find few more collection interview question.  


PalindromeStrings.java


package com.javadevelopersguide.lab.basic;
/**
 * This program illustrates find all palindrome strings from array.
 *
 * @author manoj.bardhan
 *
 */
public class PalindromeStrings {
public static void main(String[] args) {
String stringArray[] = { "eye", "jdg", "javadevelopersguide", "aabaa", "hello", "pip" };
for (int i = 0; i < stringArray.length; i++) {
printOnlyPalindrom(stringArray[i]);
}
}
private static void printOnlyPalindrom(String str) {
String oldString = str;
StringBuilder builder = new StringBuilder(str);
if (builder.reverse().toString().equals(oldString)) {
System.out.println(oldString + " is a Palindrome.");
}
}
}


Output -

29 comments:

  1. Very impressive article! The blog is highly informative and has answered all my questions. To introduce about our company and the activities, Pegasi Media Group is a database provider that helps you to boost your sales & grow your business through well-build Java user list

    ReplyDelete
  2. Greetings! Very helpful article! I came across many new ideas through this article. Thanks for sharing! Java Training in Bangalore is the best place to learn Java and Advanced Java and give you more practical knowledge.

    ReplyDelete
  3. Thanks For Sharing his nice post. Read Our Article in Fitness And Health Releted.
    web Development Company in Surat

    ReplyDelete
  4. Hi! Someone in my Facebook group shared this website with us so I came to check it out. I'm definitely loving the information. I'm bookmarking and will be tweeting this to my followers! Superb blog and amazing style and design.
    web maintenance services

    ReplyDelete
  5. If you are a beginner in programming world and want to learn programming fast. So I suggest you a a website which have projects with source code and you can use those projects and practice those projects Projects With Source Code

    ReplyDelete
  6. APTRON Gurgaon located in different places in Gurgaon. We are the best Training Institute offers certification oriented Core Java Training in Gurgaon. Our members will be eligible to clear all type of interviews at end of our sessions. We are building a team of Core Java trainers and members for their future help and assistance in subject.
    For More Info: Core Java Course in Gurgaon

    ReplyDelete
  7. There's definitely a lot to know about this issue. I really like all the points you made.
    UI Development Training in Bangalore
    Reactjs Training in Bangalore

    ReplyDelete
  8. Very nice information on java. You can also check goformule.com for mulesoft tutorials

    ReplyDelete
  9. Thank for foe explaining palindrome program thanks for your efforts angular certification

    ReplyDelete
  10. This is really a helpful blog I am really impressed with your work, keep it up the good work
    1Z0-819: Oracle Java SE 11 Developer
    1Z0-900: Java EE 7 Application Developer

    ReplyDelete
  11. Finding work is difficult in today's economic climate, especially in light of recent events (the last 18 months or so). Having a well-written and professional resume will boost your chances of landing a job no matter what your goals are. So find resume writing services in usa here

    ReplyDelete
  12. thanks for sharing a valid information a useful blog posting .

    German Language Course In Chandigarh

    ReplyDelete
  13. This is so true! I’m trying to be better with commenting on people’s blogs – but I realise that a lot of times I don’t have the mental capacity to comment on every post I read, so I try to at least leave one comment on at least one post I love for every blog .


    Study In Germany

    ReplyDelete
  14. thanks for sharing valid information and a blog post.



    Study In Germany

    ReplyDelete
  15. thanks for sharing valid information and a blog post


    STUDY IN GERMANY

    ReplyDelete
  16. thanks for sharing a valid information and a blog post.

    German Language Classes In Delhi

    ReplyDelete
  17. Thanks for sharing valuable info……
    simplyaweeb

    ReplyDelete
  18. Thanks for sharing such an valuable and informative blog.
    Java Classes in Nagpur

    ReplyDelete
  19. Great blog the content is informative and engaging. Visit my website to get best Information
    Frozen Shoulder Treatment in Surrey

    ReplyDelete
  20. Wonderful blog with great piece of information. Visit my website to get best Information
    vintage oval mirror

    ReplyDelete
  21. infomative blog, keep posting . If you want to learn about java web developer then checkout java course in pune

    ReplyDelete
  22. very valuable info your have shared. you can also read about the little prince summary

    ReplyDelete