New course! Every coder should learn Generative AI!
Try a free lesson+ 5
if int i is local variable declared in method there is not default value
public static void main(String[] args) {
int i;
System.out.println(i); // error: variable i might not have been initialized
}
+ 3
Hi Saeed Haghighi
Please use proper tags with your question. It will help others finding this question to others. Happy Coding ☺
+ 3
It's best to define your variables at declaration time.
+ 2
If you don't initialize static variables they get default. Int 0, double 0.0 and so on.
https://code.sololearn.com/c5NfHaf0d8Xh/?ref=app
Edit: change the print statement to see all default values.
0
O i think