Biblioteca Java - Blame information for rev 36
Subversion Repositories:
Rev | Author | Line No. | Line |
---|---|---|---|
36 | mihai | 1 | |
2 | public class CompareStrings { | ||
3 | public static void main(String[] args) { | ||
4 | String s1 = "program test"; | ||
5 | String s2 = "program test"; | ||
6 | String s3 = new String("program test"); | ||
7 | String s4 = new String("program test"); | ||
8 | |||
9 | //caz 1 | ||
10 | if(s1.equals(s2)) | ||
11 | System.out.println("1. Objects s1 and s2 are equals!"); | ||
12 | else | ||
13 | System.out.println("2. Objects s1 and s2 are NOT equals!"); | ||
14 | |||
15 | //caz 2 | ||
16 | if(s1 == s2) | ||
17 | System.out.println("3. Objects s1 and s2 are equals!"); | ||
18 | else | ||
19 | System.out.println("4. Objects s1 and s2 are NOT equals!"); | ||
20 | |||
21 | //caz 3 | ||
22 | if(s1 == s3) | ||
23 | System.out.println("5. Objects s1 and s2 are equals!"); | ||
24 | else | ||
25 | System.out.println("6. Objects s1 and s2 are NOT equals!"); | ||
26 | |||
27 | //caz 4 | ||
28 | if(s3 == s4) | ||
29 | System.out.println("7. Objects s1 and s2 are equals!"); | ||
30 | else | ||
31 | System.out.println("8. Objects s1 and s2 are NOT equals!"); | ||
32 | |||
33 | } | ||
34 | } | ||
35 |