enthuware.ocajp.i.v8.2.1327: local variables
Posted: Tue Dec 20, 2016 9:48 am
				
				Hi,
Local variables don't have a default value. If the enhanced for-loop is not executed because of a false condition, how can the values be printed on line 5?
			Local variables don't have a default value. If the enhanced for-loop is not executed because of a false condition, how can the values be printed on line 5?
Code: Select all
 public static void main(String args[]) {
        int i;
        int j;
        for (i = 0, j = 0; j < i; ++j, i++) {
            System.out.println(i + " " + j);
        }
        System.out.println(i + " " + j); //5. Not initialised if loop doesn't run
    }