Skip to main content

Data types in Java

Not everything in Java is an object. There is a special group of data types (also known as primitive types) that will be used quite often in programming. For performance reasons, the designers of the Java language decided to include these primitive types. Java determines the size of each primitive type. These sizes do not change from one operating system to another. This is one of the key features of the language that makes Java so portable. Java defines eight primitive types of data: byte, short, int, long, char, float, double, and boolean.

1) primitive data types
2) non-primitive data types


Java Data Types



Types
Size
Default
Range
Example
boolean
1 bit
false
NA
boolean b = true;
Char
16 bits
\u0000
\u0000 to \uFFFF
char c = 'A';
Byte
8 bits
0
-128 to 127
byte b = 60;
Short
16 bits
0
-32768 to 32767
short  s = 60;
Int
32 bits
0
-2147483648 to 2147483647
int i = 60;
long
64 bits
0
-9223372036854775808 to 9223372036854775807
long l = 60L;
float
32 bits
0.0
±1.4E-45 to ±3.4028235E+38
float  f = 60f;
double
64 bits
0.0
±4.9E-324 to ±1.7976931348623157E+308
double d = 60.55;

Comments

Popular posts from this blog

What is the difference between Selenium and QTP?

Feature QTP(UFT) Selenium Language Support VB Script Java, C#, Ruby, Python, Perl, PHP Windows (Non-browser) based Application support Yes No Browser support Google Chrome (uptill ver 23) Internet Explorer , Firefox ( ver 21) Google Chrome , Internet Explorer , Firefox , Opera , HtmlUnit, Safari Environment Support Only Windows Windows , Linux , Solaris OS X , iOS, Android, Others (If brower & JVM or Javascript support exists) Mobile (Phones & Tablets) Support Different commercial product i.e. HP UFT Mobile (formerly known as MobileCloud for QTP) Android , iPhone & iPad , Blackberry , Headless WebKit Framework Easily integrated with HP Quality Center or HP ALM (separate commercial products) Selenium + Eclipse + Maven / ANT + Jenkins...

How to create package inside a project?

What Is a Package? A package is a namespace that organizes a set of related classes and interfaces. Conceptually you can think of packages as being similar to different folders on your computer. You might keep HTML pages in one folder, images in another, and scripts or applications in yet another. Because software written in the Java programming language can be composed of hundreds or thousands of individual classes, it makes sense to keep things organized by placing related classes and interfaces into packages. -> Right click on the Project (Make sure you should right click on project, because you are creating package inside the project). -> Go to New. -> Click on Package. -> In New Java Package window, enter package name in Name text box. -> Now click on Finish . -> Now you can see the package inside the project at Project Explorer area. Now your package is ready.