It is same and both will give you same result.
Both are not same
In first code block with 'if-else' it is sure that k will get initialized.Because if 'if-test' failed than k will get initialized in else block.
But in second block with multiple 'if' statement the k is being initialized inside 'if' block
& compiler thinks that there is no else block & if 'if
test' fail than k will not het initialized
before System.out.println(k); statement so compiler gives an error in 2nd code.