0

How do we choose what type of variable to use?

criteria that make us decide which type to use among static, instance, method parameter, and local variables.

7th Jan 2018, 2:11 PM
Aminu Dzara
Aminu Dzara - avatar
2 odpowiedzi
+ 4
I guess simple common sense is all we need to decide what/which data type is to be used, for example, if we're expecting a string input, don't use a numeric type to accept the input, vice versa. Similarly, if we need a relatively small number input then don't declare a variable from a type that was designated for large number, and surely we wouldn't want to use floating point variable to accept input if we were expecting integer instead. The question detail is somewhat vague, you probably were asking about scope of variable or method rather than what/which type is to be used. In that case I would recommend you to do a search regarding "java access modifier" instead, as it is much too broad to be covered here, and I may risk from giving you invalid description : )
7th Jan 2018, 7:02 PM
Ipang
0
yes my question was close to your second interpretation, scope of variable, although not exact. anyway, I've figured it out through other mediums. thanks for trying to help.
7th Jan 2018, 7:24 PM
Aminu Dzara
Aminu Dzara - avatar