Write a Java program that compares two Strings. You have to declare a String text1 and assign it the value "programming" and then declare another String text2 and assign it the value "development". Your program should do the following:
Write a Java program that compares two Strings. You have to declare a String text1 and assign it the value "programming" and then declare another String text2 and assign it the value "development". Your program should do the following:
Chapter7: Characters, Strings, And The Stringbuilder
Section: Chapter Questions
Problem 12RQ
Related questions
Question
Description
Write a Java program that compares two Strings. You have to declare a String text1 and assign it the value "
- If the two Strings are exactly the same print to the screen "Exactly the same: True" otherwise print "Exactly the same: False". You may use boolean variables.
- If and only if the first comparison was false, a comparison should be done that ignores case sensitivity. If they are the same while ignoring the case print to the screen "Similar: True" otherwise print "Similar: False".
Sample Input
These sentences are the same. These sentences are the same.
Sample Output
Exactly the same: True
Sample Input
This sentence has Upper case and Lower case letters. This sentence has upper case and lower case letters.
Sample Output
Exactly the same: False Similar: True
Sample Input
Well something is wrong here Obviously they will get a false output
Sample Output
Exactly the same: False Similar: False
Expert Solution
This question has been solved!
Explore an expertly crafted, step-by-step solution for a thorough understanding of key concepts.
Step by step
Solved in 4 steps with 2 images
Knowledge Booster
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.Recommended textbooks for you
EBK JAVA PROGRAMMING
Computer Science
ISBN:
9781337671385
Author:
FARRELL
Publisher:
CENGAGE LEARNING - CONSIGNMENT
EBK JAVA PROGRAMMING
Computer Science
ISBN:
9781337671385
Author:
FARRELL
Publisher:
CENGAGE LEARNING - CONSIGNMENT