import
java.util.Scanner;
public class
StringOps
{
public static
void main(String args[])
{
Scanner s=new
Scanner(System.in);
String a=new
String();
String b=new
String();
System.out.println("Enter
two strings:");
a=s.nextLine();
b=s.nextLine();
String c=new
String();
c=a.concat(b);
System.out.println("Concatenated
string is: "+c);
if(a.compareToIgnoreCase(b)>0)
System.out.println(a+
" is bigger than "+b);
else
System.out.println(b+
" is bigger than "+a);
System.out.println(a
+ " in uppercase is "+a.toUpperCase());
System.out.println(b
+ " in uppercase is "+b.toUpperCase());
if(a.equals(b)==true)
System.out.println("Using
equals function: True");
else
System.out.println("Using
equals function: False");
if(a==b)
System.out.println("Normal
'==' condition: True");
else
System.out.println("Normal
'==' condition: False");
}
}
OUTPUT:
C:\Program
Files\Java\jdk1.7.0\bin>java StringOps
Enter two
strings:
foo
foo
Concatenated
string is: foofoo
foo is bigger
than foo
foo in
uppercase is FOO
foo in
uppercase is FOO
Using equals
function: True
Normal '=='
condition: False
No comments:
Post a Comment