+ 1
Java string comparison
Hello! I have written a code in which there is a character x . Now during writing an if statement, i am converting this char to string before comparison but still code is showing no output. Here's the code public class Program { public static void main(String[] args) { char x='a'; if(Character.toString(x)=="a"){ System.out.print("hello"); } } }
2 Answers
+ 2
Adnan Ur Rehman
String comparision examples:
https://code.sololearn.com/cZms6c3vg2w3/?ref=app
+ 2
Thanks everyone . Now i understood it.