Skip to main content

Posts

Showing posts with the label Explaining data types in Java

Explaining data types in Java

The Java programming language is strongly-typed, which means that all variables must first be declared before they can be used. This involves stating the variable's type and name: int gear = 1; Doing so tells your program that a field named "gear" exists, holds numerical data, and has an initial value of "1". A variable's data type determines the values it may contain, plus the operations that may be performed on it. In addition to int, the Java programming language supports seven other primitive data types. A primitive type is predefined by the language and is named by a reserved keyword. Primitive values do not share state with other primitive values.  The eight primitive data types supported by the Java programming language are :  Byte : The byte data type is an 8-bit signed two's complement integer. It has a minimum value of -128 and a maximum value of 127 (inclusive).  Short : The short data type is a 16-bit signed two's complement intege...