M
Matt
Is it a good practice to initalize all instance variables with
type String to emptry string?
#1 approach:
public class A
{ private String name = "";
private String address ="";
//etc...
}
rather than
#2 approach:
public class A
{ private String name;
private String address;
//etc...
}
When I read Java books, the examples don't usually do #1 approach.
The problem is if we don't initialize to empty string, when we call
the getter method of that instance variable, it will return null.
Please advise. Thanks!!
type String to emptry string?
#1 approach:
public class A
{ private String name = "";
private String address ="";
//etc...
}
rather than
#2 approach:
public class A
{ private String name;
private String address;
//etc...
}
When I read Java books, the examples don't usually do #1 approach.
The problem is if we don't initialize to empty string, when we call
the getter method of that instance variable, it will return null.
Please advise. Thanks!!