Java (1 - 21)
Java (1 - 21)
Language Fundameatals
lo Reserved ords G) Vai-arg methets
Dada Types main oethod
Literals (omnCind- lineargumens
Artays Jaua cdling standard
DENTEER
A namein Java programis called Tolentitier wwhich
Can be usedl foidenthkication purpose. Tt can be
method name Variahle name class name br lobel
ame
closs Tast)
public stathc wod nain)lítring Li ar)
int (M= I0
fatad idenhkier=
Rules tor Dehining Java Tdentihrs
Only allouwed chaacters are (-z Az) (o-3)
1f 0e are using Qiny otherr choracter.well get
tOmpile hme ertor fr- totalahumber
tota# (X)
Tdenhhiers rcant starts uita
Dtvs123tutal lX)
b-ava idenhhier are coae sensihve Dfoune iavs
anguage.is reatedu au ae senihve pngram ming
Cx- clas Test 2inInt number lo
we can Int Numbe 20,
differentiate wrt int NUMBER 3D
Case
There is nu length limit for jaxa idenhers but
itis not recomimended to take too length yiderhfhen
ale cant uereserye d ord a dani hers
int if20(X)
All prede hined avo claH hamesik intertace
identihiers
Qullic ztathie void oain (ringlar)
int sting
Systemioupnatla (tring)
keysind
public
to Modilisrs Keyaerdl tor Excapis
private
potected catch
Hondling
staic hinally
final
abstratt thowS
Ssnchmnizad (Lsert 4v)
nahive
tronsi ent.
valahle Chts Rala ted Keyword
class
I11 interfacR
extends
Object Related Keard implement
instan co of packagt
Impor
Super
Retutn Tupe Keyiwordthused Keynrd
L qoto
Ctonet
2
enum BRer
DATA TYPES
In Java cvery anable and evey fxpresion hau
char
5'ayte
short floating Pint boolean
int Dat Type (e)
lons
ieat double
cansaotive nuaber
1mecns
fhitivak ho vaill be represented dlidlyin membny
Labert a negctiveno uill
ail) be represtnded in
Twns omplemen t otm
bute h=)28X
oapileEmo: pastikle
pastikle lnss o precision fond
int required i byte
bte b2 l0-s
Conpite éron pacsikle Joss at precisinn koundi
double eauired byte
-3236R to 3169
Short s= 329bR X
faund tequitd therd
int 2]47y83644
decimal platesoaccunar
IEloat ollouc single llea) - Dauble tollaai
predtion doukleraarelprecicion
Size 4 bytes32 bits)
Range - -3.4eS8 to
Range 3.4e38 Range e302
BonlEAN
Size NA -No+ Apolita ble lVichucl HacbineDepeodec)
Range - NA ;But aloued Valuek are tuel halc ]
boolean b= tnie V
CE - Inoopatible typed tound int requirtdchaelao
boolean b=Ine
(E- Cannn+ fiad Symba l
Symbal : Vaniable Tnue
locathon: cos TeAt
bpoleanb"Te"a
tE- intampahible types und ijaxazlang
S0:P |"Hello" S.0:P"Helo "l:.
else 3
S s.0-p " H;:
int Dx KeerX
clax Test
public slatic vaid cmain
int w=10
int
Syatem.cud.phidtn [xtyt'z)
ecinal<br
(1oJn
MEOXID
integeral
hype but e can shecity cxplicitily as ang
precisioo found o
bngElo; reqired
There is no way diect to speimy byte ond shert
tifural explicihl, but indirecy weWe can tpecik
whsneNen aAsicghing thtegel liera
byte aiable and ' a l u z within th
Cnge o ble hen tonpiler treat it auto matady
ay byte likral imalay hart likral aleo.
TVH will aluoays provide values in deeimal o
shor t s: 32361V
Shorts Z24b X
fountiat
Teguirt d shord
e loathing paint terails.
eveny
Douklé
Dowble type and hince Lbee
tantacisn diectly
to the Hast vaniahle but we can specif lcatin
f123.T6CÆ - PLP
faunddeuble
Hoat f 23-uCfv
double
Fouad idaukle
douked=oxEote
Wdoukle d= 016
Poind itdhal O
Vdowhle do12
doubte 10
200.0
found idlouke teguedfasr
teat
BonL EAN LIIERAL
The caly alloued value tor boalean date
Anue or kalse
Vbocleanb thue
X boalean b 0 CE ncorm catible tupeA
kound : int
riqired bonleaa
X bocle an b Tnue:CE = cannat ind symbe
Symbel : vaniabie Tae
location:clas.eat
X boole cun b=tnue intarapatikle hypes
oundiava.laa Shiy
raitd Loolean!
#2 Reter boalean datahpeor mar
CHAR LTERAL
le can pehy char literal aA Singde chanatten
withi sîngle quoteA (')
Vahan c a':
chan ch a - CE- Chhot hnd Symb
Symbal : vaniale a
Coph (eh
harotten
Escape chenactensin Jave
fccape chanacten Descriphie
he ne
hoizontal tab
Canzinge. rehuh
back space
form feed
sin_le qote
doubte qucte
bock slash
4 String literad
Ay ceaueatt af chanactenk uotkin doublesate
Sting
1.3 venion ehhahtlment wrt iteras
Rinany Literals
nr inteanal data thåge
huge unt L6veaions wt Can
cpeih iferal valw in the
decimal
- hexadecimal toms
Dat
but
denal value even in binany oma also
Alleueed digits cne
ont (o1)
Herl valae should be preh oith fDE)or
(OB).
usageaunden
liHerals
tore fymbol in gumen
undencore Symbol Llu htimenic tenah
clbubled
doubled 2 3 4 h 189
deuble d 1234Ih4
The main advont e n tais copmath
hea abilihy oh fhe code willL be impmved
We can tuse
double de2-Ha-R9
byte shorti
2 byte