//Java program to compare two strings
import java.util.*;
class string1
{
public static void main(String args[])
{
String a="Welcome to Java";
String b="Welcome to C++";
String c="Welcome to Java";
//comparing strings a and b
if(a.equals(b))
System.out.println("\t "+a+" and "+b+" are equal ");
else
System.out.println("\t "+a+" and "+b+" are not equal");
//comparing strings a and c
if(a.equals(c))
System.out.println("\t "+a+" and "+c+" are equal ");
else
System.out.println("\t "+a+" and "+c+" are equal ");
}
}
Output will be similar to this :
A similar program to this :
Java Program for concatenation of two strings
12 September 2018
Java program to compare two strings
Subscribe to:
Post Comments (Atom)
To convert from Upper case to lowercase(A to a)
//converting from Upper to lower(A to a) import java.util.*; class case { public static void main(String args[]) { System.out.pr...
-
//C++ program to calculate x^n #include<iostream> using namespace std; int main() { int n,x,k; cout<<...
-
//Program to calculate LCM of two(2) numbers #include<iostream> using namespace std; int main() { int a,b,max,lcm; cout<...
-
//Program to calculate area of circle using SWITCH statement import java.util.*; class switch1 { public static void main(String a...

No comments:
Post a Comment