Posts

Showing posts with the label reverse string in java program

Prime String concept and program in Java - Explained

Image
Prime Strings: You must have heard about prime numbers. But have you ever thought about prime string?   It's very simple and interesting. Here's the explanation:-  In computer science, string is sequence of characters.Characters may be alphabets, numbers, punctuation, or special symbols. So any word is a string. for example: "Hello" is a string. Now, what is prime string? A string which cannot be constructed by concatenating two or more than two(multiple) equal strings. Let's have a string "Road" , when we divide "road" into two equal parts we get "ro" and "ad" which are not equal strings. Thus "road" is a prime string . Now let's take a string "baba". By dividing this string into two equal parts we get "ba" and "ba" . Both these strings are equal. So it is not a prime string. Here's a prime string program written in java. It also tells the first h...