johnson_homework1

Primitive Data

  • Byte is an 8 bit signed integer. Used for saving data in large arrays.

  • Short is a 16 bit signed integer. Also used for saving data in large arrays.

  • Int is a 32 bit signed integer. Integers can be used as signed or unsigned data types. Integers are used across programming and data storage. Used for typical arithmetic in code.

  • Long is a 64 bit integer. Used when the range of numbers is higher then what Int can provide.

  • Float is a single-precision 32-bit IEEE 754 floating point. Float values have a huge range as they are integers with decimal capabilities.

  • The double data type is a double-precision 64-bit IEEE 754 floating point. This is standard when using decimal values within code.

  • Boolean represents one bit of information. Its value can either be true or false and is used within loops, if statements, etc.

  • The char data type stores any strings, numbers, or symbols. Not as commonly used as the other data types.

  • Memory address is a specific location used at different levels by hardware and software. It is made up of a sequence of unsigned integers. The memory address is typically stored in RAM or Cache.

Each double contains typically 8 bytes. So if you take the number of items in your array and multiply it by 8. So an array with 20 items would have 160 bytes. 160 bytes equates to 1,280.

The number of bytes depends on the encoding system used. Typically 1 byte or 2 byte are used per character in a string. So if you have 20 characters and it’s 2 bytes per character that string would have 40 bytes. 40 bytes equates to 320 bits.

Oracle. β€œPrimitive Data Types.” Primitive Data Types (The Javaβ„’ Tutorials > Learning the Java Language > Language Basics), https://docs.oracle.com/javase/tutorial/java/nutsandbolts/datatypes.html.

Last updated