What is an attribute in Java?


I read that to get length of an array, I use the length attribute, like arrayName.length. What is an attribute? Is it a class?

This question is tagged with java attributes

~ Asked on 2011-12-12 18:28:15

The Best Answer is


An attribute is another term for a field. It's typically a public constant or a public variable that can be accessed directly. In this particular case, the array in Java is actually an object and you are accessing the public constant value that represents the length of the array.

~ Answered on 2011-12-12 18:30:39


A class is an element in object oriented programming that aggregates attributes(fields) - which can be public accessible or not - and methods(functions) - which also can be public or private and usually writes/reads those attributes.

so you can have a class like Array with a public attribute lengthand a public method sort().

~ Answered on 2011-12-12 18:36:36

Most Viewed Questions: