-
Notifications
You must be signed in to change notification settings - Fork 0
/
MatchStrings.java
53 lines (44 loc) · 1.12 KB
/
MatchStrings.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
import java.io.IOException;
public class MatchStrings {
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 == string3)
{
System.out.println("string1 == string3 is true." +
" string1 and string3 point to the same string");
}
else
{
System.out.println("string1 == string3 is false." +
" string1 and string3 do not point to the same string");
}
string3 = string1;
System.out.println("\n\nTest 2");
System.out.println("string3 is now: " + string3);
System.out.println("string1 is now: " + string1);
if(string1 == string3)
{
System.out.println("string1 == string3 is true." +
" string1 and string3 point to the same string");
}
else
{
System.out.println("string1 == string3 is false." +
" string1 and string3 do not point to the same string");
}
try
{
System.in.read();
}
catch (IOException e)
{
return;
}
}
}