0

var Variables in Java?!?!

does it exist a Variable type that gives the variable automatically his type? i mean in c# it is existing. example; var Var = 12 and then Var is a int

18th Oct 2016, 8:25 PM
Baran
Baran - avatar
3 Respuestas
+ 3
Nope, as far as i know all variables in java must be explicitly declared with a data type.
18th Oct 2016, 9:06 PM
Ousmane Diaw
+ 1
int var = 12; /*this would give you a variable named "var" and a value of 12.java doesn't automatically declare variable type. */
19th Oct 2016, 1:23 PM
Eric Kershner
Eric Kershner - avatar
0
It always pays to define your variables (even in c#) as if YOU don't know what type to set, how do you expect your program to know and capture errors? There's a saying: "Garbage In, Garbage Out" :)
2nd Nov 2016, 11:00 AM
Alan Wilkes
Alan Wilkes - avatar