Why do Java local variables need to be initialized? As mentioned. Thanks.
黄舟2017-05-17 10:00:02
The compiler cannot pass
If there is no initialization, just point to an address similar to c. So the direct compilation of java failed.
高洛峰2017-05-17 10:00:02
Compared with global variables, local variables have a short life cycle and are declared many times. If an initial value is given like a global variable, it will affect performance. Not giving an initial value is unsafe, so we made a compromise and stipulated that users need to first Assign value and use again.