but the default constructor initializes the variables to default value
//come from Core Java 2,Volume I :Fundamentals
Writer : Cay S.Horstmann && Gray Cornell
Yes! if you doesn't use default constructor to create new instance. However, default constructor can still be used to create new instance even if it has nothing.
Default constructor CAN initialize the instance variables declared in the class. However, it CANNOT do it if you doesn't write the expression of the assignment in the default constructor. Therefore, the statements is not 100% right, only partially.
default constructor can initialize instance variables but when u use the
variable ,it will get the value u give it.
if u and the default constructor all don't initialize instance variables
how can u use the instance variables not initialized ?
找到个相关例子://括号内是和例子相关的
We give our class instance variables to support reading from and writing to (socket streams), and to (store details of the remote host to which we will connect0.
The constructor for our class (takes an IP address and a port number for a remote host and assigns them) to instance variables.