-
Notifications
You must be signed in to change notification settings - Fork 0
/
MatchStrings2.java
63 lines (54 loc) · 1.33 KB
/
MatchStrings2.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
import java.io.IOException;
public class MatchStrings2 {
public static void main(String[] args) {
String string1 = "Too many ";
String string2 = "cooks";
String string3 = "Too many cooks";
string1 += string2;
System.out.println("Test 1");
System.out.println("string3 is now: " + string3);
System.out.println("string1 is now: " + string1);
if(string1.equals(string3))
{
System.out.println("string1.equals(string3) is true." +
" So strings are equal.");
}
else
{
System.out.println("string1.equals(string3) is false." +
" So strings are not equal.");
}
string3 = "TOO many cooks";
System.out.println("\n\nTest 2");
System.out.println("string3 is now: " + string3);
System.out.println("string1 is now: " + string1);
if(string1.equals(string3))
{
System.out.println("string1.equals(string3) is true." +
" So strings are equal.");
}
else
{
System.out.println("string1.equals(string3) is false." +
" So strings are not equal.");
}
if(string1.equalsIgnoreCase(string3))
{
System.out.println("string1.equalsIgnoreCase(string3) is true" +
" So strings are equal ignoring case.");
}
else
{
System.out.println("string1.equalsIgnoreCase(string3) is false" +
" So strings are different.");
}
try
{
System.in.read();
}
catch (IOException e)
{
return;
}
}
}