Difference between fields and variables(java) | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
0

Difference between fields and variables(java)

Can anyone explain to me what is main diff between variable and field in java with examples...

17th May 2020, 10:42 AM
Subhan Ahmed
Subhan Ahmed - avatar
2 Answers
0
a field A data member of a class. Unless specified otherwise, a field is not static. and Variable is An item of data named by an identifier. Each variable has a type, such as int or Object, and a scope. See also class variable, instance variable, local variable.
17th May 2020, 11:00 AM
Abdelkhalk Ait Elhaj
Abdelkhalk Ait Elhaj - avatar
0
A field is a variable property of a class. It's like variable but for a class. Also called attribute https://www.sololearn.com/learn/Java/2218/
17th May 2020, 12:57 PM
Ore
Ore - avatar