Friday, 21 October 2016

Write a java Program to Perform String Operation

import java.util.*;
class StringOperation
{
  public static void main(String args[])
{
  String first=" ",second=" ";
  Scanner sc=new Scanner(System.in);
  System.out.println("String_Operation");
  System.out.println();
  System.out.print("Enter the first string1");
  first=sc.nextLine();
  System.out.print("Enter the second string2");
  second=sc.nextLine();
  System.out.println("The string are:"+first+","+second);
  System.out.println("The length of string is:"+first.length());
  System.out.println("The length of string is:"+second.length());
  System.out.println("The lowercase of"+first+"is:"+first.toLowerCase());
  System.out.println("The concatenation first and second string:"+first.concat(""+second));
  System.out.println("The first character of"+first+"is:"+first.charAt(0));
  System.out.println("The uppercase of"+first+"is:"+first.toUpperCase());
   System.out.println("The lowercase of"+first+"is:"+first.toLowerCase());
  System.out.println("The occurance of a character in "+first+":");
 String str = sc.next();
 char c = str.charAt(0);
 System.out.println("The "+c+" occurs at position" +first.indexOf(c)+ "in" +first);
 System.out.println("The substring of "+first+" starting from index1 and ending at 4 is:" +first.substring(1,4));
System.out.println("Replacing 'a' with 'o' in" +first+" is:"+first.replace('a','o'));
boolean check=first.equals(second);
if(!check)
System.out.println(first+"and"+second+" are not same");
else

System.out.println(first+"and"+second+" are same");

}
}

3 comments:

  1. Netflix mobile apps are available for Android, iOS, Windows platforms. You just have a premium membership of Netflix that’s all; you can enjoy your favorite TV shows or movies anywhere, anytime
    windows activators

    ReplyDelete
    Replies
    1. Check out this website for free projects www.coderush.cf

      Delete
  2. Hi, Great.. Tutorial is just awesome..It is really helpful for a newbie like me.. I am a regular follower of your blog. Really very informative post you shared here. Kindly keep blogging. If anyone wants to become a Java developer learn from Java Training in Chennai. or learn thru Java Online Training in India . Nowadays Java has tons of job opportunities on various vertical industry.

    ReplyDelete