-3

I want to compare two strings. When one is uppercase and other is lower case. How to verify that var1 is uppercase and var2 is lowercase using java string comparison method?

 String var1 = "HELLOWORLD";
 String var2 = "helloworld";
PM 77-1
  • 12,933
  • 21
  • 68
  • 111
Jay Peris
  • 3
  • 2

2 Answers2

0

You can use equalsIgnoreCase from the Strings library:

if (var1.equalsIgnoreCase(var2)) {
  // do stuff
}
CheeseFerret
  • 597
  • 11
  • 21
0

you can see this solution you can try it.

String var1 = "HELLOWORLD";
String var2 = "helloworld";
if(var1.toUpperCase().equals(var2){
System.Out.Print("test success");
}
else{
System.Out.Print("test failed");
}
Abdalrhman Alkraien
  • 645
  • 1
  • 7
  • 22