Samplejava =
package ong.sample;
public class Saeple {
public static void main(string[] args) (
4 (22-0) (
h System.out.printIn(at" is even nunber");
»
alse (
system.out.printIn(at" is odd number");
bh »
>
BD Sample java
print odd number from 1 to 10
package org. sample;
public class Sample {
8° public static void main(string[] ari
For (int ie1siceresit+) {
if(i82I=@) {
n system.out.println(i);
+
a
B consale 2
Sample) v2 Application] CAP
41 is odd number
= 0 Gcons
termine
1
3
5
7
9
@ HarishkumarD Somplejave 12 = BB console 2
a -terminated> San
2 //2nd maximus number in array 208
3
4 package org. sompl
3
& public class Semple {
7
fe public static void main(string{] args) (
2 Ant [] renew Ant[3]5
° or[0]-100;
2 ar(1]-200;
hz ar{2]-500;
3 S-[23]-400;
a or[4]-200;
hs
6 for(int Sa@s Scar Lengthsitt) {
3 for(int joist; Scar Lengthiit+) {
9 sForliart5})
° int tempear(i]s
2
2
2 >
4 ?
$
6 systen.out.printin(a[2])3
7}
2)
DB) "Samplejave 52 26 Aonsole 52
re terminated Sor
11304 winimum number in arcay +0
package org. samples
public class Semple {
public static void main(string{] args) {
int [] arsnew int [5];
icar. lengths j++) {
CorLi}eor[5}) (
int teap
ar[i]ear{i]
ar[J]etem
,
system.out.peintIn(ar[2])3D) “Semplejava 53 | [) Statjava Omjva = EiConsole £2
1 Ge) | ctemminated> Semple (1) Pave
2 //reverse each word in the string venoclew ot avaj ssalc
3
4 package org.sample;
5
6 public class Sample {
78 public static void main(String[] args) {
8 3
9
ho
ha String{] 53 = si.split(" ");
2 for(String 54:53) {
b> String 55=""5
ba for(int iss4.Jength()-13i>=@5i--) {
hs char c = s4.charat(i);
he SSesStc5
hs s2es2+s54"
bo +
a System. out.printin(s2);
GD Somplejava 2¢ |) Statjava_— (J) Sting Matham..)Owjna = Console £2
public static void main(String{] args) { © sterminated> Sem
int i=5; five
sudteh(1) {
case 1:
‘system. out.println("one"):
‘system.out println( One");
break;
case 3:
‘systen.out.printla(“theee"),
break:
System.out.printha(“four")s
breaks
case 5:
‘system. out.printla( “five”
case 6
‘Systes.out.println("six");
ce
‘system. out.printin("seven”);
‘system. out.println(“eight");
‘system.out.printla(“nine");
break;
case @:
‘system. out printla(*zero"
break;By “Somplejave t2 )Statjava Sting. Mathamatcsjova (7) Orgjava Siri ax %|
. 1 steminted> Sat a Appian] C
2 Hcount of all caps small digits special count with special methods SealizLaerscarorapeailcon
3 Gapitaieicee
4 package org. seeps Digie=ssaenp321
Special characters=>2
D
? {hse ss(enractertauppecene(a))
> ) aes
ft fase ss(enractere01gt9)) (
7 Selensiien
b: )
bs “ase ¢
b7 ‘spclespcies
bs »?
fo —_Systensout.prtnin( setton"t4"a0>"tmalt;
" Eyatensotprintln( Copitleey*taresvcapas
a Brintin(igieen)nees-4dig)y
Es Syitealou print -apecial Characterssticht"as"6apel)s
=)
D) Semplejeva & | [7] Statjava (7) String Matha... [J] Orgjava «= = ©) Console iy
1 5 sterminated> Sample (1) Jv
2 /Heonvert first letter of the each word should be in co Welcome To Java Class
3
| package ong. samples
© public class Sample {
28° public static void main(steing[] args) {
8 ‘String sis"welcone to jove class";
9 ‘string 52
8 String] 53 * st-split(”
ba for(String 24:53) {
2 ‘char ch = 24,charht(O)3
ba char =~ Character. taUppercaze(ch)s
ha String 5 © s4.subctring(1);
hs sueszentoe”
hs }
ha System.out.println(s2);
Hs}
haDSimpejove | Seine Ogi "= Console
© cterminted> Samy
2 [print duplicates in array :
pestge og sees
© public class sonple (
oP lpplde static vold mxin(string{] args) (
: nt []isronew int{7]3,
he for(int a0; car Lengths$t4) {
hy for(int joieis car lengths3+e)
hs erty) €
hs ‘system ouf.println(ar[1]);
2 ,
" >
O-seoein 5 a ee Ey Cem
i | stein Sample:
2 Lipetnt woke ua in areoy Beate 6)
4 page ores
ort
4 public class sample (
oP lpanlic attic wold aan(Steingl] ergs)
ne} sronae tat13,
° setcanteger> list + new Teeset0o()s
° ‘for(int to; earstengensit)
: arlistender(iD):
2 ?
2 steweprimtnanie:
a
Dseroeime | DSi DSiegiaramete. Osea Ocane
i | ert Sept
3 sramone dicate fom ering ore
{pcg ses
Start
Spork vest
5 pie lass soote (
bile seat wold matastng) ents) ¢
Seing sietwicone to ee
oy
Stent bey
System tpi)
SOT acter
Sapctaracterjieege'> pene Linkeansiapo(
iter enh)
antataioy te) (
ee
‘Smtten tle 8
>
2
Jeccentoyecnaracter, Imegen> eteyset = npcenteyset():
for fencryctareeer, Integers emery eresse)
ieseygeteayt
}
Sytem ot pine:saan» BY eens
rsa ene Re
4 package orestles ees
neteeat sme
- Rie,
EL.
sens coe
2 Vote vor vases inthe stein | aka
: ze
‘eae ioe
Se Amore fovautth-s a
2 Sire $0 ee eye s
2 malic clans Sete
eget fee ee emer Mew Hlem v) €
Trteger inte = so-get(chTLD)s
sentie, ays
»
base ¢
papwt(es 395
g 8
Seecenerycenaracter,Integers> enerysee = npentryset()z
For (Entryecharscter, Tateger> entry # eneeyset)
Systenout.prdntin(ert ys
Ose Se
t ome BURT eee
Uaetcrane 228
© public class sonple (
public attic sold main(String) ose) {
‘String se'velcone to joveclans toby"
Shorld chs sstacherdrenOs
Sat Sounds
Bae sc tens) (
en
Ghee!) || cone
eet
eireeng
[emu feeea ene fener" eme'o'Heme v9) {D Senate jne #7 | ee SUB) Stemi
: = XE
public static votd wainstring() args) ( oe
Se es
aca eee arr al =
Sear taaNesce z
MoE nroremcere (
HARUM ASANTE ttewetteweten tawny (
ass at
eee ae ecartgy
eta
,
pee
hte
)
3
Lccseemumanapsanen Gia
Seta ee ay
Sacre
)
Bs
Dsenpinjen (ETSRTESED 1p Suing Metharestcsjun () Orpjon = 01 | Dcenete 12 [WISER
5 See SGI SESTEOSSSISEESEN | corntuats ate ese?
E pane
3 pecags or. sep; erasers
3 pre
5 ee cam set extend ee Sein Geto
Peptic static vod nan(stng or) (
saetng stepancanszgerad cons
int 209, co0, 70,
String Sealio"™jcapse™”ydigite
for(int is0;ieel-Length(dsio8) €
‘har 9 = s1.cnarat (3);
Se(ar978@9ce122) {
peall-smell05
spelt
»
‘ee it (areesttece90) {
capescapstay
eigiteaigitees
y
else (
spclespclta;
| yeten at phat “satien "etter senl)
Syaeen on princia(enseaio=
System. out printla(“Digiten>"¥n#"
system out printla( special tharacteres)"chDSeroeive *|BiSatine Seg homasne Ol BIB] come
1 | ceminaat Save
20 public class Semple {
fie" public static vod main(string[] args) throws Parseteception {
a ‘String dts eueze-20-20")
E> ‘Sapleaetetornat sf = new Siepledetetoreat("yyyy 4d");
Ee (alonder = Calender _petfastancel
Le Settle oahparse( ey)
ke loda(caiendardniéy 20)3
g SOS Beets et ine())s
2 Sytenoutsprincingis
fs}
=)
Dsampejore |G) Saja Sting Matamatsias — ([}Omjaa | OConsce 12
: © terminate Sample
2 /Hinerease the current sonth by 2 dene
4 pctageoressmples
Ge tnport javactentParsetnceptions
0 public cass suaple {
2 public static void sain(string[] args) throws Parsetxception {
2 String dt = vaese-10-20"), : ‘
a Steplevaterormat sof = new SinpleoateForwat("yyyy--dé");
< (olendor «= Calendar getinstonce( 3
hs EvsetTine(sat.parse(ai))s
he cada(Colendars nom 235
hb ft sa fornat(ergetTine());
he fenovtprintin(st):
a)
20 >
Dsnpeina % Satine Sing itomaine DOgine | Qconmie =
7 © steminated> Samy
2 //inerease the current year by 2 3923-10-26
4 package ong.samples
= Inport java.text-Parseexception:
Y Giport Javectert Sinpledeterormat
8 mort javecutl.colender;
20 public class sample {
jie public static void aain(String{] args) throws Parsetaception (
2 ‘String dt = "2020-18-28"
3 ‘SlapleoateFormst =f = new SinpladateFormat( "yyy Ide");
¢ Calendar c = Calendar. getinsconce(}:
. Satine (oatsparse(de))s
(Calendar Yea, 3)3
Gi sof format(c.getTane()):
Systen.ovtsprintin(et);BF Semplejava £2 = 0 | SConsole 52
© terminated> Samp
/Ireverse the string ellen
package org.sample;
public class Sample {
ousune
7
8® — public static void main(String[] ergs) {
9 10";
String :="hello";
ho String rev=
faa for(int i=s.length()-13i>-054--) {
h2 reverevts.charat(i
3 +
ha System.out.println(rev);
bs}
16
7
D Semplejava 5 =O Bconsole 23
‘© tetminated> Sam
Mpalindrone of string Palindrome
package org.sample;
public class Sample {
public static void main(string[] args) {
‘String s="malayalan”;
String reve"
for(int i=s.length()
reverevts.charat(i)3
si)
+
i f(s-equals(rev)) {
‘System.out.printIn("Palindrone'
BETH TRURE Som NounuNe
else {
‘System.out.printIn(“not a palindrome");
}B) sempiejave 52 = 8 Bconsole 5
Nousune
a8
9
he
ha
ho
bs
ha
bs
16
v7
/Tprint even number from 1 to 600
package org.sample;
public class Sample {
< Sample (1) Ja
530
532
534
536
538
540
public static void main(String{] args) { 342
for (int ist;ice600;it+) {
Af (3%2==0) {
system. out.println(i);
}
G Semplejava £3 |
/Tcount 04 nunber from 1 to 100
4 package org-sample;
public class Sample {
public static void main(String[] orgs) {
5
6
7
88
9
he
hi
ha
3
hs
hs
hs
7
a8
i
3
Ant count «0:
for (int ie1;ice109; i++) {
if (i210) {
count:
¥
}
Systen.out.printIn(count);
548
546
543
550
552
554
556
558
562
564
566
568
570
572
574
576
578
580
582
584
586
588
590
592
594
596
598
= B | BConsole 23
+ Sample (By “Samplejava £2 | = Bconsole 12
2 © Sample
2 //check the number is prime or not = Prime nusber
3
4 package org.sample;
5
© public class Sample {
z
8© public static void main(string[] args) {
9 int 9913;
0 int count = 0;
ha for(int ix2;icna/25it+) {
2 iF(aKi==e) {
3 count++3
ha }
hs }
hs iF(count==0) {
h7 ‘System.out.println("Prime number");
he
hs else {
2 System.out.println("Not a prime numebr");
a }
bo}
a 2
28
TD) Semplejava 5% 2B BConso
3 © terminate
2 //print prime number from 1 to 50 2
3 2
4 package org.sample; 3
5 5
© public class Sample { 7
: n
© public static void main(stringl] args) { B
9 for(int intica50;i4+) { ”
ry int count = 0; 19
ha for(int j=25j 37
5 } a
hs iF(count==0) { 43
7 System. out.println(i); 7
3 ?
hs }
2|B Samplejava 52
a
2 I/remove duplicates in array 10
3 20
4 package org. sample; se
5 4
5° import java-util.LinkedHachset; 30
7 import Java util sets
8
9 public class sample {
20
18 public static void main(string{] args) {
int [] arenew int{3};
SetcrInteger> senew LinkedHashseteInteger>()3
for(int 1=05icar.lengthsit+) {
s.add(or[])3
for (Integer acre: 2) {
Systen.out.printn(acr)
}
0
31
a er ta funoer of characters in string -12
package ong.sample;
bli class Sample (
public static votd wain(stringl} args) (
String se'weleonedi23";,
har{] eh = s-tocharaerayQs
ne Tengen = chlengehs
5 steal rintin rte ofearctrs in string sents
Ose Sy Saar «x Ki
teminated> Semple (1) ave Apc
Meets cunber of words hunber of words in string =>5
a
package ong
& public class Sample {
Be public static void main(String!) ores) {
3 String se"weleowe to. jova class today";
ho aa teen
ha fine length = chen
i System out.prineln(enunber of words Sn string
|S
st= 0 | SConsole 5
© Sar
Jiget number and print it in words WELCOME
ENOCLEN
D) Semplejava 22 |) Statjava J) Orgijava
4 package org. samples
5
6 public class Semple {
78 public static void main(String[] args) {
3 String s="Welcome";
9 string si
ho String rev=
ba char{] ch = s.tochararray();
ho for (int is0;i=0;i--) {
bs char revnum = ch2[i]3
bs reverevérevnum;
b7 }
8 System.out.println(rev);
G) “Sempiejava 22 (Z) Statjave — G)Orgjva GE Console 52
1 *— sterminated> San
2 //print only numbers in the string 123
3
4 package org. sample;
5
© public class Sample {
78 public static void main(string[] args) {
8 ‘String s="hellol23hai'
9
@
of
String £2="
char{] ch = =.tochararray()s
for(int is0;icch.lengthsit+) {
ho char c= ch[i]3
hs iF(@o='0°BRCCR'9") {
4 s2es24c3
hs }
6 x
h7 System.out.printin(=2)5
8 +BD) Somplejava 22 | = B Console 52
: | steminaed> Sar
2 //ascending order in array 100
3 200
4 gecdage org. seple} tee
s 6 500
fee
© public class Semple {
7
88 public static void main(stringt] ergs) {
9 int [] arsnew int{5];
ho ar[0]=8005
ha ar{1]=2003
2
3
pa ar[4]=1005
bs
hs for(int Sa0;icar. Lengthy iss) {
b7
hs for(int joist; jcar-Lengthsie+) {
bo $F(erli}arliD) {
bo int tempear[i];
a ar[i]ear(i]s
p2 ae[s}etemps
23 2
bs >
25 2
ps for(int imdsicar.lengths itt) {
b7 ‘System.out printin(er[i])$
bs }
ps
38
31
BD) Sempiejave £9 2B BConsole 23
‘Uidescending order in array 800
500
package org.sample; 400
200
public class Sample ( 100
J public static void main(stringt] args) (
int [] arcnew int[5];
ar[o)=109;,
ar[a}=200;
er{2}=500;,
ar[3]=400;,
ar[a]=800;
for(int is@;icer-lengthsit+) {
hs for(int jaitazjcar-lengthsi++) {
ho if(orfi}eeri}) {
bo int’ tempzar(i];
a arli}-erli]s
2 ar[j]=temps
b3 }
bs }
bs 5
bs for(int i-@;icer.lengthsit+) {
b7 ‘System-out.printIn(ar[i])s
bs >
bs
302B Bconse
* }
B Samplejava 13 | [) Statjava 2) Orgjeva™
a
2ose seeee
= ese
”
package org.sample;
10
11 public class Sample {
2% public static void main(String[] args) {
h3 for(int iatsice5it+) {
ba for(int j=13}<=5-it1;j++) {
hs ‘System. out.print(**")3
bs }
h7 System.out.printin();
hs +
po}
20
a“Samplejava 22 20 BConsole 22
© sterminated> Sem
J/maxinum number in array =| a0
1
2
3
4 package org. sample;
5
© public class Sample {
7
ve
9
Lic static void main(Stringf] orgs) {
ie Deo
he art
by or] -209;
2 or[2] 509;
" ar[3]=400;
hs seL4] 0003,
he for(int S0;Scar.lengtnsi64) (
fe Fert sik: tens jeae NaRBTIATC
bs H(erEs}
6 ‘System.out.printIn(ar[@]);
E>
2
B) Somplejove 13 SB Console £3
1 © terminated» Sart
2 //winimum nunber in array 100
3
4 package org. samples
6
public class Sample {
58 public static void main(stringt] ores) {
° ‘int [] arenew int[S]3
he ar[o}-108;
pa o-[2]-200;
2 sr[2]-s00;
bs ar[3]=s00;
bs -(4]-200;
bs
hs for(int sn85 Scar. Lengths t+) {
hb?
ps for(int j=itl;j
bs system.out.printin(ar[0])3
?
22
23Bh Sec 2] DF Statjava 3) Org java = 0 Console 23
Sa
package org. sample;
10
21 public class Sample {
28 public static void main(String[] args) {
3
4 for(int in05ic55i44) {
hs for(int. j=03 j=
hs 4
h7 }
3 Systes.out.println();
ho }
ae
2
22
Decco 2] ) Statjava — [d) Org.java = 6 OConsol
terminate
per a 1
> 2 2
a 123
5 1238 1234
6 12345 12345,
2|
3
9 package org.sample;
1
11 public class Sample {
2© public static void main(String[] args) {
h3
ha for(int in@;i public static vod mn(string(] orgs) {
Se
gia,
2 Se
Bement te
D Semplejava 5%
‘Hswap two num with 3rd variable
package org.somple;
public class Sample {
public static void main(String[] ergs) {
int 2010;
int 6-205
Systen-out.printIn("a="+a)3
System. out. println("b="+b)s
int tenp =;
abs
ten
Systen.out.printin("a="#3)3
system-out.printIn("b="+b)3Don: Sy ss
a | terminated» Sample
2 //reverse the musber 123 a
>
4 package org.semples
© public class Sample {
?
be public static void main(string{] args) {
° int nom =1235
ho int rev05
ha whie(nume) {
2 int nenuakae
3
ps
bs ¥
hs System.out.printn(rev)s
wy)
7
19
© Console £2
_terminated> Semple () 8
‘Ueneck palindrone munber palindrome musber
package org-canple;
public class Semple {
7
Se public static void main(String{] ares) {
° int nun 922521;
2 Ant tenponun}
a int revo;
2 whide(non>e)
3 int nennhie,
< revecrev"10)40
S un/=105
6 y
7 St(reventenp) {
2 ‘Systen-out-println("palindrone munber*);
2 >
2 aise (
2 ‘systen.out.printin(“not 2 palindrone number");
2
3
0 soocoe Some «x elk
3 eons rmbur of gic timber of digits in the given nmber=3s
eb sat wold misting) es) ¢public static void main(stringl] eres) {
Systes.out.printin(count);
y
dinom & [RS IySaas
1 | terminated> Samp
2 /Iprint even sum from 1 to 98 27
£ package org. samples
& public class Sample (
7
5% public static votd main(String] arse) (
° int sun =03
ho for (int $2; i<=905it+) {
ht S6G82==0) {
h2 suns!
3 }
a iF
S Sprtmetspintintoms
a
Jiprint odd sum from 1 to 88 1600
1
2
3
+ pte areceyiny
6 public class Sample {
?
52 public static void main(String[] ergs) {
9 int sum -0;
ho for (int in1;i<80;i++) {
| if(iK2!=0) {
2 suntel;
3 }
4 }
nS System.out.printIn(sum) 5
6 a
7DD Somplejava 53 = 0 BConsole 23
a © terminated> Samp!
2 //swap two gum without 3rd variable alo
3 b=20
4 package org.sample 20
5 be10
© public class Sample {
7
8° public static void main(String[] ergs) {
9 int
e int b=205
ba system.out.println("a="+a);
h2 ‘System.out.printIn(“b="+b);
hs ‘anatb:
he bea
as aea-b3
he ‘systen.out.printin(”
h7 System.out.println("!
bs}
hs
20
BD) Semplejava 2 = BConsole £2
a | Sarr
2 //Factorial of the number 5 120
3
4 package org.sample;
5
© public class Sample {
?
8© public static void main(String[] orgs) {
9 int 395;
ho
ha int fact=1;
2 while (390) {
hs Fact=fact
ha
hs }
hs System. out.printin(fact);
7
18Kindly Follow 0 @Hariskumar