R
Rod
I recently saw some code that looked like the example below ..
my question is why the developer used
"this(SOME_WORDS)" in the constructor for SomeClass.
Seems to me that the static string array SOME_WORDS would have been
available to SomeClass without this code in the constructor ....
========================================================
public interface SomeWords{
static final String SOME_WORDS[] = {
"Tom",
"Dick",
"Harry"
};
}
public class SomeClass implements SomeWords {
public SomeClass() {
this(SOME_WORDS);
}
public void sillyMethod() {
System.out.println("I am here");
}
}
my question is why the developer used
"this(SOME_WORDS)" in the constructor for SomeClass.
Seems to me that the static string array SOME_WORDS would have been
available to SomeClass without this code in the constructor ....
========================================================
public interface SomeWords{
static final String SOME_WORDS[] = {
"Tom",
"Dick",
"Harry"
};
}
public class SomeClass implements SomeWords {
public SomeClass() {
this(SOME_WORDS);
}
public void sillyMethod() {
System.out.println("I am here");
}
}