Search code examples
javaattributes

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?


Solution

  • 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.