How does Boolean store memory

2.2 Data types and ranges of values

These data types are implemented using Java classes. The data structures created in this way are Java objects and have a different life cycle than primitive types used in a Java class or a programming block.

Complex data types (Java classes) have a variable large storage space requirement. They are created on the Java free memory (heap).

Strings are not a predefined primitive type in Java. Strings are in the package java.lang with the help of the class String implemented. The class String however, it can be used like a primitive type without a special declaration.

Strings cannot be modified in Java. A new data structure is created for each assignment. For primitive types, the values ​​are overwritten in the same place.

Enumerated types have been part of the language since JDK 5.0.

Enumeration types
Enumeration types in Java have a range of values ​​that consists of an ordered set of constants. The current value of a variable consists of one of the enumeration constants

Enumeration types can only be declared as part of a class. Like the other base types, they cannot be declared within a block. The syntax of a declaration in a class is as follows:

Example of a declaration in a class:

class AufzaehlungsDemo {enum card color {diamonds, hearts, spades, cross} enum weekday {MONDAY, TUESDAY, WEDNESDAY, THURSDAY, FRIDAY, SATURDAY, SUNDAY}}

When using enumeration types, only a previously declared enumeration constant can be used.

Example of use in a class method of the associated class:

Weekday today = weekday.WEDNESDAY; Card color lady = card color.HEART;

Enumeration types were implemented like reference variables (which will be presented later).

Reference types allow referencing to other objects. They are covered in Section 7.

The Java BigDecimal classes allow calculations with any precision. BigDecimal classes are not covered in this introduction.

Stefan SchneiderSat, 10/29/2011 - 14:48