Re - declaring a local variable or function is not really a good practice.
Instance class variables and functions can be from the current class or from a parent class as explained in
the inheritance section of this chapter. Note that functions can be overridden but variables cannot.
The scope for enum s is the current file or every package imported; this argument is covered in Chapter 6 .
Finally, you can have a static field and an instance field that share their name but you can ??™ t have a class
variable that shares its name with a class function.
Constructor
Every class can be instantiated only if it has a constructor that is a special function that is invoked every
time a new instance is created. The syntax for the constructor is almost identical to that of the instance
functions with the only exception for its name that must be mandatory new . The function return type is
always Void and can be explicitly stated or omitted.
Because instance variables can ??™ t be initialized in the same place of their declaration, the constructor
should be used for this purpose.
Pages:
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237