I have a really basic question about using new
in java statement. For example, the return clause at the very end uses new
for String
. Why String
here needs to be created? Under what kind of situations would people choose to use new
?
public class A extends java.lang.Object {
public int number;
public String toString() {
return new String("Value : " + number);
}
}