JAVA EXAMPLE PROGRAMS

JAVA EXAMPLE PROGRAMS

Publish Your Article Here

Java Data Types

Java is a strongly typed language. Part of java's safety and robustness comes from this fact. You can broadly classify java primitive data types as given below:

Integers

Java defines 4 integer types. These include both positive and negative numbers.

Type Size Reference Example
byte 8 bits byte x,y,z;
short 2 bytes short x;
int 4 bytes int num;
long 8 bytes long millise;

Floating point numbers

Floating point numbers are very useful when we are evaluating expressions that require fractional precisions. Java defines 2 types of floating point numbers, they are float, and double.

Type Size Reference Example
float 4 bytes float percentage;
double 8 bytes double distance;

Characters

In java we store characters by using char data type. Size of character is 2 bytes.

Example:

char a='c';

Booleans

In java we use boolean for logical values, it can represent either true or false.

Example:

boolean isNumber=false;

Next Page: Variables

Knowledge Centre
What is servlet context?
The servlet context is an interface which helps to communicate with other servlets. It contains information about the Web application and container. It is kind of application environment. Using the context, a servlet can obtain URL references to resources, and store attributes that other servlets in the context can use.
Famous Quotations
Be yourself; everyone else is already taken.
-- Oscar Wilde

About Author

Most Visited Pages

Other Interesting Sites

Reference: Java™ Platform Standard Ed. 7 - API Specification | Java is registered trademark of Oracle.
Privacy Policy | Copyright © 2017 by Nataraja Gootooru. All Rights Reserved.