Reading:  

Quick introduction to Java Programming language - Part 1


Data types in Java

Each and every variable in the Java must have a data type. The memory allocation to the variable is based on the data type.By assigning data types to variables, user can store integers, characters or decimalsin these variables.

Categories of data types in Java:

  • Primitive Data Types
  • Derived/Reference/Object Data Types

Primitive Data Type: is the basic type, which is inbuilt data type of java.

  • Variables declared with primitive data type are known as primitive data type.

Primitive data types are:

 

Data Type

Description

Memory Size

byte

Byte-length integer

8-bit two's complement

short

Short integer

16-bit two's complement

int

Integer

32-bit two's complement

long

Long integer

64-bit two's complement

float

Single-precision floating point

32-bit IEEE 754

double

Double-precision floating point

64-bit IEEE 754

char

A single character

16-bit Unicode character

boolean

A boolean value

true or false

 

Syntax:  data-type variable name;

Example:  int age;

 

Derived Data Types:

This is customized data type of java.

  • Variables declared with deriveddata type are known as derived data type.
  • Mainly used to store the reference/address of an object created,Class objects, and various type of array variables come under reference data type.

Example:

Creating object for Account class

Account a1 = new Account(“Savings”);

Here, a1 is derived data type. 

 

Java supports few escape sequences. They are:

  • \n: It is used to points the cursor to Newline
  • \r: It is for carriage return
  • \s: It is for space
  • \\: backslash
  • \t: tab
  • \f: It is for formfeed
  • \ddd: It is for octal character (ddd)
  • \": It is used for double quote
  • \': It is used for single quote
  • \uxxx: It is for Hexadecimal UNICODE character (xxxx)

 

Description

This tutorial is targetted for beginers seeking a quick get on with guide on Java programming language. 3 parts include 

  1. Java basics
  2. Object oriented programming
  3. Advance concepts

Each part is subdivided in multiple chapters.

Java basics has the following chapters

  1. Introduction
  2. Environment Setup
  3. Basic Syntax
  4. Objects and Classes
  5. Basic Data Types
  6. Variable Types
  7. Modifier Types
  8. Basic Operators
  9. Loops
  10. Decision Making
  11. Numbers Class
  12. Character and String Class
  13. Arrays
  14. Date and Time
  15. Regular Expression
  16. Methods
  17. Streams, Files and I/O
  18. Exceptions Handling

Thanks for reading and as always, your feedback is very important to us. Let us know how we can improve and if you found any issues with this write up, send us a correction.



Audience

Beginners or students seeking a refresher on Java language

Author: Subject Coach
Added on: 9th Mar 2015

You must be logged in as Student to ask a Question.

None just yet!