class Tips0031 {
public void someMethod() {
//When calling an assignment statement or method, it is difficult to understand by simply writing null, so it is better to specify the type.
//In the following cases, it is not necessary to specify it.
String str = null;
//
//However, when the variable declaration and the assignment statement are separated, it is better to specify them.
//
//Other processing
//
str = (String)null;
//
//Also when calling a method
otherMethod(null);
//It is better to do as below than above
otherMethod((String)null);
//
}
//
private void otherMethod(String str) {
//Some processing
}
}
Recommended Posts