Skip to main content

Posts

Showing posts with the label string

String Palindrome

AJ Java Programs Program 8: String Palindrome: A String is said to be palindrome if  it conveys same meaning when read from front or back Example  MADAM, DAD, MALAYALAM etc Syntax: import java.io.*; class str_palin {     public static void main(String args[])throws IOException     {         BufferedReader br=new BufferedReader(new InputStreamReader(System.in));         String s,rev="";         System.out.println("Enter a string to reverse It");         s=br.readLine();         s.trim();         int l=s.length();         for(int i=l-1;i>=0;i--)         {             rev=rev+s.charAt(i);         }             if(s.equals(rev))             System.out.println("It is s...

Piglatin

AJ Java Programs Program 7: Piglatin When in a word first character is moved to last and "ay" is added to it it becomes Piglatin Lets See how to do it. Syntax: import java.io.*; class  piglatin { public static void main(String args[])throws IOException {      char ch;    String word="",str="";    int i;    String s;    BufferedReader br=new BufferedReader(new InputStreamReader(System.in));    System.out.println("Enter a String");    s=br.readLine();    s=s.trim();    s=" "+s+" ";    for(i=1;i<s.length();i++)    {        ch=s.charAt(i);        if(ch!=' ')        word+=ch;        else if(s.charAt(i-1)!=' ')        {            StringBuffer sb=new StringBuffer(word); ...

Remove Duplicate Characters

AJ Java Programs Program 6: Remove Duplicate Words From String Example:             Input: blogger output: bloger Syntax: import java.io.*; class RemoveDuplicateCharacter {     public static void main(String args[])throws IOException     {         BufferedReader br = new BufferedReader(new InputStreamReader(System.in));         System.out.print("Enter any word : ");         String s = br.readLine();         int l = s.length();         char ch;         String ans="";                   for(int i=0; i<l; i++)         {             ch = s.charAt(i);             if(ch!=' ')                 ans = ans + ch;   ...