Saturday, 26 July 2014

How to Check the Equality of TWO STRING IN JAVA

Structure of the Problem Requirements 

String is the important data type in programming. In Java there are many functions of string which are use to manipulate the records which exist on string. in this problem we have two string and we will check the equality of that string . The string will be equal if and only if they have same length and character.

Source Code

package com.stringmatch.www;

import java.util.Scanner;

public class Compare_string {

    public static void main(String[] args) {
      String a ="";
      String b ="";
      Scanner input = new Scanner (;
      System.out.println(" Enter Your Sentence ");
      a = input.nextLine();
      System.out.println(" Enter Your Sentence  ");
      b = input.nextLine();
     if ( a.equals(b))
         System.out.println(" Sentence Match ");
         System.out.println(" Sentence Does not Match ");

Output of the Program

Java String Programming
Java String Programming

Java String Programming
Java String Programming

Share it Please

About Author!

Asad Niazi is Software Engineer , Programmer, Web Developers and a young mentor of Tech Solutions Desk and Blogging Solutions . Asad Love to writes about Technology, Programming, Blogging and make money online.


Post a Comment