Java_Notes
Java_Notes
YOUVA
Date:
block of code.
else
(blo ek otf Code
1 Cond:tion evaluakesexecuted,
to other
then block is
else block is executed.
Date:
(condition )
eseit
Alock of cooe
I/
ése tlock otcode
M T
Page No.
Date: YOUVA
Date:
he m ANing
IS Conposed 3 parts. he te h¥ny
consis bs o 3 operandls it is sed to
oper akan boolean exressin : he opemato decick
eyaluate
ohich alue oill be assiantd to the variable.
It Can be uicd insteas o i-elae. nakey the
code uch moneeasyi meadable Qno shont
aageaniate
vanale
caba type vamable Cordition ? Expnessioni exprË AS
on
ig corcl'tion evaluates bo, tee then walue o
Crp.1 is asigned bo the vaniable, otheNo0se value ofex
21s asgneol to the vaniabe.
W T
YOUVA
| Date:
*Soibglatemen:
usebooheck
Condibions like if-elseif-else. sta mulbiple
enent.
instead of using any else i stotcroents,
Sioitb statement canbe used.
Syatas'
aiteh (expresion)
Case
lcode
beeak;
Case vaue '2::
beeak :
detault
match i h an
expression does hot letault blocki
specitied alue te
Cxecated.
roamami"s e h e )
Stafihe Seenher
-println( nEnter No"))
yctem.out new' Scanney(SysBemiin
Int numse' sc.nextLnt0
JCannem
Stoitchlnum)
Case1
Sop ('sunclay
breaki
Case
Sop C"'Mon day ")
becak
Case 7
Sop ("Satuclay"),;
bsea k
detaulti
Sor ("ovalid Ahpu")
Abo ve poroqr a
inhu
accepts ' on
if hunbe
nteger
entereo by,
useYTS hen pog ints unglay
numbey ent ere
2then its Monclay
usEN Enters
Lohichis
erend
Jess
studen
than
number
is
Page No.:
YOUVA
Date:
hile ( Condibion)
t executes the black ot11 isolso
Condition evaluates to t& ue 1+
called as exit conleaocp. becatuse, ît
checks the condIion atler block ot code
is executed.1 Condition eyaluates to Fose
then lock of code is exeeuted eee.atleast
Paanam bo
to
,print
the hum
num bers
humber
ber enterc
by User
T
Syctem.out-prints C" nter, he buob
Scanner Sc neo Sconner(System.n)
se hextIntO;
nt = 1;
clo
YCUVh
do
Sop Ci);
Syslemgu.printin(i);
in! numbedJom
bo no. e n e e d
|Page ho.
YOUVA
|0ate 23-|-24
cxe Cutes he
statement foroop
unkil Conalikio n evaluntes
teue. As qs the Condibion
Satified the
the for lbop
temninates.
Gor (inibialiealisn i Consltion; ineaemenolec
eement)
blact o cocde
abovésyntax inibializationvaniable.
repnesernts Initializatlon
Condibiorn epsents an ¬xpmess ion thal,
False.
Inceement dectement vaniable
also cone in ianatune ot To loop.
for loap executes ie block ot code nti|)
ondition evaluates
-ion Evalual,es bo Talse then cursoy
Cocle lock
Page o.
Dete
YOUVA
vamigblg
Atler Inikializalsion
place, Condition s evalua teosue
erECuted. Ather
then
Condion cualuates is oleceement
block ot Code
that Incsfment place. Jhen conditiog
variable takes nt its
IS, cvaluatedl
execuHon aga bl»ck vano
alecsemento
ondhen inesemenbrepeat edly Hlt condi tin
Fakes tlace to
evaluates
hummbeps.
9um be pntesed y se
javq- util)
Class oanJavg
publk statie void nain (sing Iga
System.out.printn" nterr a' number
Soanner sc new.SCanner ystem in
int,n sC-ncxtIntl),
tot Cint i=1 iKDtt)
ycten out printdn(oi );
Page No.:
YOUVA
Date:
In enter
above example ausen
co
1 to
anumberr. Nurnben.st
numbe.nL9
the
oyuSer (ne pe in fed.
Synka
tan(olalatype varia ble : Callec biorn)
Dste
allecion elements o
Atsay ;: Collection
Sane dababype: cseated using
In ava Q220y S
Syntax: databype [I@
ollooing akle ncu
olatatypeLvaniable
Iside
size mepresents
Ta above synstax to be mesent in
Dumbe of elements
emple-Steing(s hame,s
Steingl];
o
ceafeo
ammay names' is delementsit
Penre, Maxioum
detaultsize g ie, anyay. Num ber of eleme
an
Can be stare in an amay js known a:
çnts stomedn
length ofan amay
elepents/iems bo aniuma
Syntax to add (index] valuej
amayName
mepnesents an index hunben
Hee index
which start tonom Zer.
AgyEsLo] =
asnmyNamelder]: value
A1
piyusha
Sayali
hames 21 11 Gautamn }I!
Page No.
YOUVA
Date
mintin Crame);
oystemeui
Achantages.
opbimisation Sont alata/en
"HeCaadecan
netsive
Enents etiiently.
random Access aaba/ item I:elehmer
con oeteive any: position.
He atspecific inolex.
Jocatead
Disadvantag
iSize jsTinc :
only fixesizei of
Ne con store anmay. The stze ot
of ay
elements in an atrun tlme Colynamicing
does not qmow froblem linkecis
list
To solue this
use
Single dimensional onay (Nateix)
24 Malti dlimengiono amoy
+ayyltt -dimensional amay h such
*aMwti
Dt, is an amray of aray columm
Cue, daba is'stomedi in now and
basec inden.
a<so knoon as mateix.
dababype
Page No.:
Date: vOUVA
Syn ta '-.
datalye rooscolumrs varriable =ndaba typ< CJtJ:
Ehample '
int 2] [3J a: neo Int[JJ:
Hereuse have Ceeated bwo oliensien
al aay hauing ts0 -vBws and a column
ohich epresents 2x3 matx
* Agslaning element to multidlimeng ional
ammay
We can Qssign value bo
to malai using
rou anol eolunn, tnolex
any LrooIdex] columnIrex] yalue :
Example
We have assiqnieaalue s to mateix
postion having mow inge n Lcoumn index.
e sccond aw & secondelumn.
entigteoping Hheouah myulbidimentional ma
He ean iterabe toop throuah 2 olimen,
-sional arnay using nestecl ov loop.
As chao below. Whenenepmesents mow
inae x anod J' vepresens olu mnindeK.
Page No
Date:
12,2, 2
intJJ
{4,4, 4
f4, 4, 43
Page No.:
YOUVA
Date
Date:
YOUVA
(Deignatio Employe
(emait 7Sala
(Dept)
Cla tengloycr
Lora idi
Ssing
StEina
deot
clouble _alay
ssing sesint atjon)
Class Test
fublic static void tpa in (Steing
Syntan for userdefine asabype iery clas
classname yariable: heuo clasnamelJ!
Date
a instance of a clas
Object is£mployee is a clasS Ghd
Coject' example
Th abey ohjects of that elass
enpi, empa
Somé cxp. as of class.
Exanple
Class Employee
int i i
staing
Page No
YOUVA
Date.
Emdloyee Gint
this id-i
i, &teing n, Steing
this StIrgn)
this Steha: e
elass Test.