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
Can we call servlet destory() from service()?
As you know, destory() is part of servlet life cycle methods, it is used to kill the servlet instance. Servlet Engine is used to call destory(). In case, if you call destory method from service(), it just execute the code written in the destory(), but it wont kill the servlet instance. destroy() will be called before killing the servlet instance by servlet engine.
Famous Quotations
I don’t know the key to success, but the key to failure is trying to please everybody.
-- Bill Cosby

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.