Skip to content

Commit 1090cd2

Browse files
authored
Update StringEqual.java
1 parent d05bf3c commit 1090cd2

1 file changed

Lines changed: 5 additions & 13 deletions

File tree

pitfalls/StringEqual.java

Lines changed: 5 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,14 @@
1-
package com.zetcode;
2-
3-
import java.util.Arrays;
4-
51
// the program throws a NullPointerException
62
// we should swap the sides: "rock".equals(word)
3+
void main() {
74

8-
public class StringEqual {
9-
10-
public static void main(String[] args) {
11-
12-
var words = Arrays.asList("wood", "forest", "falcon", null, "sky", "rock");
5+
var words = Arrays.asList("wood", "forest", "falcon", null, "sky", "rock");
136

14-
for (var word : words) {
7+
for (var word : words) {
158

16-
if (word.equals("rock")) {
9+
if (word.equals("rock")) {
1710

18-
System.out.println("The list contains rock");
19-
}
11+
System.out.println("The list contains rock");
2012
}
2113
}
2214
}

0 commit comments

Comments
 (0)