One more point:
The strings are a normal point of memory problems. Many times in a system exist allot of object instances representing an equal String. The String has the method String.intern() that gives the some Object instance (99% true) for equal String.
Code: JAVA
String name1 = new String("Timmy");
String name2 = new String("Timmy");
if (name1 == name2) {
System.out.println("The strings are equal.");
} else {
System.out.println("The strings are not equal.");
}
if (name1.intern() == name2.intern()) {
System.out.println("The strings are equal.");
} else {
System.out.println("The strings are not equal.");
}
Output
Code:
The strings are not equal.
The strings are equal.
So, if you have allot of equal Strings, you can consider to have: