Java Programming - 1
Java Programming - 1
ex:-
1. class example
2. {
3. public static void main(String args[])
4. {
5. System.Out.println (“This is a sample program”);
6. }
7. };
Introduction
• Java is case-sensitive language.
2. Floating-point types
3. Characters
4. Boolean
5. Literals or Constants
Integers
1. Java does not support unsigned, positive-
only integers.
Name Width Range
Long 64 bit -------------------
int 32 bit -------------------
short 16 bit -------------------
byte 8 bit -------------------
Integers
1. The width of an integer should not be thought of as amount of
storage it consumes but rather as the behavior it defines for
variables of that type. The java run-time environment is free to
use whatever size it wants, as long as the types behave as you
declared them.
3. short:- short s;
double 64 bit
float 32 bit
• ex:- boolean b;
Literals or Constants
1. Integer literals
2. Floating-point literals
3. Boolean literals
4. Character literals
5. String Literals
Integer Literals
1. Decimal integer literal has no leading zero.
• ex:-
// this fragment is wrong
count = 100; // cannot use count before it is declared
int count;
ex:- int a;
byte b;
b = (byte) a;