Line | |
---|
1 | package eu.hsrw.tr.prog.vl.einfuehrung; |
---|
2 | |
---|
3 | /** |
---|
4 | * Demonstration der Vergleichsoperatoren mit Strings |
---|
5 | * @author Thomas Richter |
---|
6 | * |
---|
7 | */ |
---|
8 | public class Stringvergleich { |
---|
9 | |
---|
10 | public static void main(String[] args) { |
---|
11 | String a = "java"; |
---|
12 | String b = "java"; |
---|
13 | |
---|
14 | // true |
---|
15 | System.out.println("a == b: " + (a == b)); |
---|
16 | |
---|
17 | String c = new String("java"); |
---|
18 | String d = new String("java"); |
---|
19 | |
---|
20 | // false |
---|
21 | System.out.println("c == d: " + (c == d)); |
---|
22 | |
---|
23 | // true |
---|
24 | System.out.println("c.equals(d): " + c.equals(d)); |
---|
25 | } |
---|
26 | } |
---|
Note: See
TracBrowser
for help on using the repository browser.