Sunday, November 3, 2019

Check whether a string is Palindrome or not , in java

  • Check whether a string is palindrome or not..


This program helps to find the given string is palindrome or not.


//Program code
import java.util.*;
class Stringdemo
{
  public static void main(String args[])
  {
     System.out.println("check the any String is palindrome or not.");
     System.out.println("please enter any string");
     String name,duplicate="";
     Scanner obj= new Scanner(System.in);
     name=obj.nextLine();
     int length;
     length=name.length();
     System.out.println("length of the string="+length);
 
       for(int i=name.length()-1;i>=0;i--)
       {
   duplicate = duplicate+name.charAt(i);
       }
          if(name.equals(duplicate))//String function to compare the string
          {
        System.out.println("yeah! string is palindrome");
          }
            else
            {
          System.out.println("oops! string is not
palindrome");

OUTPUT:







           

Tuesday, September 3, 2019

Hello World program in Java

This Simple "Hello World" program helps to you that how Java programs are constructed and executed.

/*Simple program to print HELLO WORLD*/

class Hello
{
      public static void main(String args[])
      {
            System.out.println("HELLO WORLD");
       }
}