Hello, i have a question. How do you compare 2 words or integers? the idea is a program should prompt the user to enter 2 words in one sentence (so like "apple orange") then it reads the 2 words and compares them to see if they are the same or not. Thank you!
beGinneR24
0
Newbie Poster
Recommended Answers
Jump to PostValue comparison is done with the == operator.
For instance, the expression (5==5) will return true.
This operator works with all numerical values as well as with characters.
To compare strings, use the syntax (str1.equals(str2)).
For instance, ("apple".equals("orange")) will return false.
All 2 Replies
Reply to this topic
Be a part of the DaniWeb community
We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.