Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What is the definition for a "Java programming language type"

Searching the web I didn't find a definition for the term "Java programming language type". I stepped over it several times, when I was reading Oracle's JEE tutorial:

  • 28.2 Types Supported by JAX-WS
  • 29.2.4.1 The Request Method Designator Annotations
  • 29.2.6 Extracting Request Parameters
  • 37.1.2.3 Using Collections in Entity Fields and Properties
  • 37.1.6 Embeddable Classes in Entities

Sometimes I think all Java classes are meant by the expression, including those I define myself, sometimes I think only those that are shipped with Java.

If a "Java programming language type" is just any Java class, why do they use such an expression here? Also I found the term "Java programming language class", but I think these two things mean the same.

like image 290
armin.miedl Avatar asked Jun 13 '26 14:06

armin.miedl


2 Answers

The full formal definition of type is what is defined in the JLS at the following link.

Basically in java there are two kind of types:

  • primitives
  • references

Primitives are:

  • int
  • long
  • short
  • byte
  • boolean
  • char
  • float
  • double

References are:

  • classes
  • interfaces
  • type variables
  • arrays

All others definitions are for types supported by some framework or libraries.

like image 151
Davide Lorenzo MARINO Avatar answered Jun 15 '26 04:06

Davide Lorenzo MARINO


Sometimes I think all Java classes are meant by the expression, including those I define myself, sometimes I think only those that are shipped with Java.

If a "Java programming language type" is just any Java class, why do they use such an expression here? Also I found the term "Java programming language class", but I think these two things mean the same.

Classes, whether you or the someone else wrote them, are just one kind of (sub-) type.

As referenced in the answer by hagrawal, the JLS is your best bet when it comes to terminology:

  1. Types, Values, and Variables

The types of the Java programming language are divided into two categories: primitive types and reference types. The primitive types (§4.2) are the boolean type and the numeric types. The numeric types are the integral types byte, short, int, long, and char, and the floating-point types float and double. The reference types (§4.3) are class types, interface types, and array types. There is also a special null type.

In fact, reference types also contain type variables:

4.3. Reference Types and Values

There are four kinds of reference types: class types (§8), interface types (§9), type variables (§4.4), and array types (§10).

These were listed in Davide Lorenzo MARINO answer (except for the null type).

like image 44
user1803551 Avatar answered Jun 15 '26 05:06

user1803551



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!