Skip to content

Commit bbecb32

Browse files
committed
Define a constant instead of duplicating this literal
1 parent 084817f commit bbecb32

File tree

1 file changed

+5
-4
lines changed
  • serialized-lob/src/main/java/com/iluwatar/slob/lob

1 file changed

+5
-4
lines changed

serialized-lob/src/main/java/com/iluwatar/slob/lob/Forest.java

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,7 @@
4848
public class Forest implements Serializable {
4949

5050
private String name;
51+
private String NEWLINE = "\n--------------------------\n";
5152
private Set<Animal> animals = new HashSet<>();
5253
private Set<Plant> plants = new HashSet<>();
5354

@@ -105,16 +106,16 @@ public String toString() {
105106
sb.append("Forest Name = ").append(name).append("\n");
106107
sb.append("Animals found in the ").append(name).append(" Forest: \n");
107108
for (Animal animal : animals) {
108-
sb.append("\n--------------------------\n");
109+
sb.append(NEWLINE);
109110
sb.append(animal.toString());
110-
sb.append("\n--------------------------\n");
111+
sb.append(NEWLINE);
111112
}
112113
sb.append("\n");
113114
sb.append("Plants in the ").append(name).append(" Forest: \n");
114115
for (Plant plant : plants) {
115-
sb.append("\n--------------------------\n");
116+
sb.append(NEWLINE);
116117
sb.append(plant.toString());
117-
sb.append("\n--------------------------\n");
118+
sb.append(NEWLINE);
118119
}
119120
return sb.toString();
120121
}

0 commit comments

Comments
 (0)