Trevor
Trevor

Reputation: 31

What is a "type" as mentioned in the Java tutorial?

Source: http://docs.oracle.com/javase/tutorial/java/nutsandbolts/variables.html

You may also occasionally see the term "member" used as well. A type's fields, methods, and nested types are collectively called its members."

While defining member the tutorial uses the term type, in this context it doesn't look like they mean data type. I can't find a correct definition on Google. Maybe its something obvious that I'm missing?

Upvotes: 3

Views: 105

Answers (3)

Dev
Dev

Reputation: 12196

Java has 3 types.

  • ReferenceType - classes, interfaces and arrays

  • PrimitiveType - primitives

  • NullType - null

These are defined in the Java Language Specification section 4.1. Any time you see an API doc or tutorial referring to a type, this is what they are talking about.

In this particular case the tutorial is using type to refer to a ReferenceType. The definition of a class and interface (a type) will usually also define members of that type.

Upvotes: 2

Sergey Kalinichenko
Sergey Kalinichenko

Reputation: 726589

In this context "type" means "class".

In other contexts it may mean "a class or a primitive type", but since they talk about types having members, they mean specifically classes. Same goes for nested types: only classes can be nested inside other classes; all primitive types are built into the language, and cannot be nested.

Upvotes: 8

Jonathan
Jonathan

Reputation: 3644

Seems like they mean the class of an object.

Upvotes: 4

Related Questions