0% found this document useful (0 votes)
1 views16 pages

Java Unit 3

The document discusses various aspects of Java programming, including input/output operations, data handling, and multithreading. It covers concepts such as streams, encoding, decoding, and the Runnable interface for thread management. Additionally, it touches on lambda expressions and functional programming features introduced in Java.

Uploaded by

shalinisri249
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
1 views16 pages

Java Unit 3

The document discusses various aspects of Java programming, including input/output operations, data handling, and multithreading. It covers concepts such as streams, encoding, decoding, and the Runnable interface for thread management. Additionally, it touches on lambda expressions and functional programming features introduced in Java.

Uploaded by

shalinisri249
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 16

Tava

In Tava, _Steuns aola WANd o inpt ud aurput apations


by allouio data to b sead fom o wutten toa daua
aot dastinatißn
Java o<u tuo types a
9) Stueam

Alpucia chouactaAtuom Byte staan

bata. Haudling kondlla choactu-bak handls xaw binday


data data

Ropstbantation ClaAALJ and with


Inputaeam
"outputieam
Litabl fo tual data, afoirg, Non-ottual data
himan-aeadabla iny
Chaocha Chcodig Automdie oing NO Ghnoding ot
VO.

uoding dacolig
Vs No tut data Rxt-baund dola,iy daig, audo,
staig Nadio nagu
Additiong) obuion eiint to
data

Handl Iog
text ile
Ahcoding may hyat yiünt,no
Gnoling ohod
Conviniunt mthod Nat zpadfkalby
ton ataing suntion duignsd fos stoihg
gpmdtion
Coninont1 Higlut-Iaul abstaactionu
mathos fa t t dato fo byi data
Rioding tins Conuiriunt mttha t Ryu-ogtrdd.,
Lading inu. ho
tading-linu. Inthd
filu Hundlirg Raod Abit text ile Rsod|koite binaxy
lea
ouad
the nabat unit c
pouaing. QXCLion
) laads ou indaþaxdunt I tuu occuuy thouod thun
it dou not Quct th attu touod Ouphôn in onu
Noto At atimo nu thocod culd ondy
ie Qycha thh ttuuods in IOva do cÔntalld by Toya
Lbtual Machin

2)Runabl
) Ruving
NOn-Annabl CGlockad)
5) buninatd
Slat) [Nu
RLunabl alp donsI<o (omplali bck
avaibabl oTU,
, woit
Nori Rumabla
(Bhockul)
Aunpig
mhod buminatod Alup , block on I<0, wait fos
lock, supund., natity
4

Th thoandis in thu huw atot uhun you cao an inaIOna


hvuod claas but ba<axg th inuocation aq saat ) mtthod
9) Runnabla
hu tosnd s in the XUNnabls atath a<uy ttu invocation
AtCHl () muthod but tu thuad bchadudsx ha not Alúc adit'to

3) Running
hy ttuauin thu xuning atau i tu thouod hudulx has
halocod t

Noh Runnabla (Block)


hat digiblu to sun
5) lazminaibd its
hy ttuuad in thy osrminatad ax dad atoth kihon aun c)
mithot Qito
*Multitonding in
Tava-:
Mutuadig
thoadb ainlauaualy
poaaings. Muuftouatng Mudtipicusis g bath oge uad
to adiu mulitaskug

It doas n't bloxk thh wsb bucouss thoodo ao inda por dond
yau can piodoum huu tipl gpualion, at the saun fm
YL Can pijoun mary apton togathaM, Jo it JOMeS
tim
houada au indapandnt to it dauAn't a4act tto otha
thoaad i thuy QccU Qxnption in on.ttotad
lasada

) by extending thu ttauad cdas


u ouala a nauu cda, that extond io laug Tfowod cdas
hu <las Quenids thy ouun() miho avaitou in thu houod cas
Athound

th oution g ttuade kioxt() ivok Ln) mthd on thy


ound obËuct
ExQmplu
chus Multi oxterdb haad
public void sunc)
Syune outopintin(
uklic atatic void Prin (thsig As [1)L
Muti t ==nw MuUti
t sat0:
inatostial

clab, Mul1i3 implniu Runabl


Rublic vaid unc)

puutiic staic vd ain (abing q ) 4

Multi3_ mË nDMuli3 ()
houad tË
In Tava, Rando Wbito 0 obstect dQWAM in tho java lo
pag that handu chaoocdy Abuaun y duirud to
Ouadig nuiling texu dala nat thu iray data
tatu
RAad

Ad to Q0d chaacbu
text data Ltot dota

Comhon ile Road, filasuto,


SubclaA.
Inputstoeanfuod IngitstuanAbilL

Thput loutpt IhputCouad fsom. Output (oit,.


to a dastiiation
dip1 a file
Nothod oQad) ou0dline), inb), appund),
AXamplu Pluahc) on().

Encodig Coun ba uwappad


IhputstueanodoL woith Outputätacan.
Andoy foiaKodig
nped jua io
public claus Radxtauplo
pullic atalic vojd noo (Stity o u)Houws 10 EX0ptan
ile Rrodon ouodunu fiuRodo Cirgut tt")
int ch:

3
Uadue cdoC)

impot /ova" io.*


public ch)s hbitafxomp
pLublic stoticvaid main (Staing oga(1) thous To Exupionl

good
Uhil-3
t Function "Llof0a
abstocd hdhod.
9) hey can law ondy ond tunctionaliy to lbit
3) bam Taa SE 8 OnwQada, Iaumba opoubaions can bs Asd to
ApNLDAndainaang a fundtiongl ints fau
9)9functioro) inoyaa con how gn o dyaul nathd.

aditiauly Ncognizad as singl Abateoct Muthod


9) FT. in jon axo ttu nw foatuxg in java thatpouid u
an appsoach oy tundamuial poagmming
8) FI: u indudo in
Muthod aLJDUNG in odo to_maka cod noe o0 adablu
dhon aaightfosund
) funxtional huacu aoo ttu inba|aa that enuna hat
thuy includ potd, ondy, ony abatxd muthod
o)functionalinb'acu d eautbd by opxtaanting
tho Intoyadnith an. anngation catlud a @Furction
Inlufaa
)Tn fI, thuu dà no nud to abatoact Rlyuoxd as
it is optioral to SIhact Ruuosnd bacoa
tha nattod dyinad ünuida tha intenaA 0A akatactny
Uvood1 pullic void vwn){
Sqbten Qut poírdinC'Nuw yhuuod Cooled);

Uaing lanbda Gxpu sion

public AtaiËc vaid main((Ating bgp )

FInolafonAb Latd to anautbat afI. ant haw

masy than bn Qbaoc mathod ib Uatd, comilt


gs an Uhuxgachd FI aNulttion mA ag.
HoLURH, It is not NaaNay toto wsUse_0nnototien.
Fuxtiontiraofaca
Indojao Sqiaxa
Int alcudatt (int 1)

pubaic Stotiç void nain (Sbing qogp (1 )


int Q=53

int. ans = $ calcudat (a)i


Suutun-aut paintln (ana)3

Y AVa Poudainad functiond Tnlibfaca..


Copuuns
fuction dru -Suppin
Poedicatn
TOAt Condi tjàa Ratdicat
MOst uand
Functona Iniolau Conms Somsthirgonmt C

funtion
ulúdh aou placad in an uil
tunctia poka
Lrlbfaa bascxption
Bi-onumwt<1,U>
that accapl two input
bgUTAru wtuoy)

II 1eDuanls an opation.
qumunt oatun no
funton<LR I mpun a fuxtion
that acupb asingu

Cboohan valusd furction)


Roalsan aupplis
ohich hoe à thou bloc cod at accapo inpul Q

Launbda Capaioin Ayniax


Iunbda 0poato - "body
int g, Steing cog2) {Syslen Qul-findn("uo frqunnla:
Aagi t and"tavg)}:
Aouw
ugunent tokun Body o 4ambda

balou

) Single paamslb
3 Mutipla pauanalivo

) lQmbda Exp uith ingla poanalux


(þ) ’{Syalm -Qute paúntin (" Ringl1 Roriale tþ)i
3) 1ombdo p' wth huipi ponaurts
cpL,þ) foygtm outpinttn (" Mulipl paxaundlina
WIthout lnbda Cp'

publi vad doaw);

public Ataie vod main (Alairg ogs(1)


ind wdh lo
public void hawc)
dptom Out þuintln (" rauing' túdth)

With lanbda Exþ'


public cdosu lambdaExgouionEunplhf
publi atatic void main (Aicing Aags[1)
inticthlo
thudth) ;
d dotgC);
Ba4 G4 ncodo Dacodo

9 ho java" (til- BaasG4 cloas paovidu slic muhods to a KOdo and


dcod bw bias gnd Boun G4 osals
2) hu oncodo ()_ad dhcod () malthods ou usd
hoding sdare that cOnwD birgy data
Io texi fomat o HHi, ercodud toxtuol data c0n ba
aDl npod,uncGYSUpld ond withaut ay y dota lou.
9ho TuA oddsd to
coding nuuu ho ino foad choaces
tho
Azazo9 in thychaat and daccdri soac any
0 ncodo any stoing, got tt encodor tthed iost by
muthod
public clas Encodobacoda
Qrblic slalicvâd nain C3tinglAuç )i
t#Outthing Cncodoy
BOAn G4 Encodon encod = Ba Go qat êncodb1);
*enoig teing
Stirg Sta encods encode ToSlirg ("ABES fng caltye
gatytut);
Sylem Out þoúntún ("rrodi Alaing:"iai);:
# Guting Dacodon
Bau 6- Docodo dacodo BaaL G4 qutbacodo);

sking dst na Stoing (dicodune daccda 0);


bysKm aut paint n (" Dacodad Stang, tdsb);
Outþut
mcodud Sting QUJrC Bbndp
Dicotad 3tain: ABES Lginuamg calg
a
URL

public caw Encod1 Dscodk


pukic cdaa Rtotic void main (Saing URoqgs)
# autting Encodt
BasisyEncocby gncod= ROn64e qe,Enot0;
# ncodig URL
Sting erxodue oncodaloSting ( hitp»|ahu-acin|"
gtbytu);
Syteme Out þåntn (" Enodal uRL:fue );
# ting Dacodon tot
Baun G DA COdun dcod = Eaun64 qtbALDacodes ();
# Dacodíng URL
Stingdsts=
Syabime Quts þuúrtln ("Daodd URr t dat);

You might also like