cdjd bf.k.ksuq
yeoskaùu
fuh Object Oriented Program tlls.
Object Oriented Program j,g Wodyrk
1. SIMULA67
2. SmallTalk
3. C
4. C++
5. Eifel
6. Java
Pdjd ksss¾udkhlf,a James Gosling úiska Sun Micro Systems wdh;kh hgf;ah.
· Tyqf.a wruqk jqfha Hardwares u; wvq ld¾hla mejfrk mefrk mrsos C++ Wmfhda.S lrf.k fuh ksraudkh lsrSugh.
· kuq;a Tyqf.a wruqk widra;l úh.
fuysoS w;qre M,hla jYfhka Oak program language Ml ìysúh.
· Oak ksraudkh jqfha C++ j, wkjYHh Features bj;a lsrSfuks.
· Oak j, ;snq Feartures
· Multiple Inheritance
· Automatic Type Conversations
· Use of Pointers
· Memory Management
· 1994 oS fuys ku JAVA f,i fjkiaúh.
1996 oS Java 1.0 fkÜ Mlg ouk,os.
fuys oekg mj;sk kj;u version Ml Java 2 jdk(java development kit) fjhs fuh www.javasoft.com fjí wvúfhka download lr.; yel.
1994 oS Java Applets fjíBrowser j,g Mlaúh.
· 1996 j, mej;s Conference Mflka miqj kj idudcslhka 1000la Sun Java wdh;khg nojd.kakd,os.
Java versions
1. J2ME
2. J2EE
3. J2SE
Java ´kEu OS Mll jev lrhs Mkï Platform Independent fjhs.
Source code()wms ,shk fldaâ Mlhs.fuh case sensitive fjhs.
Byte code()fuh Java j, mukla mj;S. fuh class file Ml f,i i,lhs.
(Java plat form Independent jkafka fuu class file Ml ksidhs. Java run time environment Ml mj;skafka fuu class file Ml run lsrSughs.)
Machine code() fuu code Mflys mj;skafka Binary number system(1,0)Mlhs’
fuh OS Ml yryd CPU Ml detect lr.kS.
Installing Java
XP ,Vista ;=,()
1. Java Development kit Ml Install lrkak.
2. Java Configure lrkyeá
Mla User flfklag mukla Java Install lrkjdkïUser Variable hgf;ao
ish,a,gu Install lrkjdkï System Variable hgf;a….
Program1
fuh fldgia 4 hgf;a bf.k .ksuq’
1 fldgi- Source Code Ml ,sùu
fkdaÜmEvh open lr.kak’
oeka ,shuq………
Pro1= program Mlg fhdok kuhs’
ish,q letters simple jkw;r String ys Mia mukla capital úhhq;qhs’
public class pro1{
public static void main(String args[]){
fuu ia:dkfha wjIH ;djg wkqj source code Ml ,shhs’
}
}
hïjpkhla command prompt Ml ;=, print ùug ie,eiaùu.
fuh ioyd System.out.println(“ Print ùug wjIH jpkh”)
fuys System ys Mia capital úh hq;qh’
public class pro1{
public static void main(String args[]){
System.out.println("Hello World");
}
}
2 fldgi- Source Code Ml Save lsÍu
Ctrl+s
fuysoS ku ioyd Program Mflys kug ,nd÷ka pro1 hkako Extension Mlg Mkï “‘” j,ska miqj java hkako m,nd oshhq;qh’
3 fldgi- Source Code Ml Compile lsÍu
Command prompt Ml open lr.kak
Windows key+R
Type cmd
Enter
oeka Tn Sourse Code Ml save l, ;ekg hdhq;qhs
Mkï pro1.java fj;’
fuh ioyd Tng wjIH jk Keys
Tab key- hï Directory Mll File/Folder w;r udreùug
fuysoS wod, File Mflys fyda Folder Mflys kfuys uq,l=r mukla ioyka lr Tab key Ml Press lsÍfuka myiqfjka wod, File Ml fyda Folder Ml fidhd.; yel’
CD(Change Directory)- hï Directory Mlla ;=,g hdug CD hkak kug l,ska Type lr Space Mlla ;nd Enter lrkak’
program Ml ksjerosj ,shd we;akï wod, directory Mflys Class File Ml iEfohs’(Byte Code Ml)
4 fldgi- Program Ml Run lsÍu
fuh 3 fldgiska fjkia jkafka
“.java” Extension Ml uld oeóu iy
Javac fjkqjg java f,i Type lsÍuhs’
You've just written your first Java program! Congratulations!!
Escape Codes
1) \n
2) \t
3) \b
4) \r
fuu Codes Print jk jpkfha úúo fjkialï lsÍug Ndú; lrhs’
1) \n
fuh lirh kj Line Mllg f.khdug Ndú; lrhs’
ex:-Program2
public class pro2{
public static void main(String args[]){
System.out.println("Hello\nWorld");
}
}
oeka fmr mrsos Compile lr Run lrkak’
Output
1) \t
fuh Tab Space Mlla ;eîug Ndú; lrhs’
ex:-Program3
public class pro3{
public static void main(String args[]){
System.out.println("Hello\tWorld");
}
}
oeka fmr mrsos Compile lr Run lrkak’
Output
3) \b
fuh BackSpace Mlla ;eîug Ndú; lrhs’
ex:-Program4
public class pro4{
public static void main(String args[]){
System.out.println("Hello\bWorld");
}
}
oeka fmr mrsos Compile lr Run lrkak’
Output
4)\r
fuh lirh mj;sk Line Mflau uq,g lrirh f.khdug Ndú; lrhs’
ex:-Program5
public class pro5{
public static void main(String args[]){
System.out.println("Hello\rWorld");
}
}
oeka fmr mrsos Compile lr Run lrkak’
Output
fuysoS Hello hk jpkh print ù lirh uq,g f.dia World hk jpkh print ù we;’ Mu ksid World hk jpkh mukla osiafjhs’
Output ish,a,
Statements
· Program Mll hï fohla is÷ùug ,shk fldaâ Mlla fuf,i y÷ka jhs’
Eg; System.out.println(“”)
· fuu.ska Single Action Mlla is÷fjhs’
· fuh Mla ,hska Mllska fyda ,hska lsysmhlska iukaú; úh yelsh’
· fuu.ska Value Mlla Return ùug wjIH ke;’
· yeu Statement Mlla wjidkfhau “ ; “ fhosh hq;=h’
· Statements Compound lsÍug ”{}” Ndú; lrhs’
Expressions
· Statement Mll l=vdu wdldrhhs’
· fuu.ska Value Mlla Return fjhs’
· fuh Variable ioyd Statement Mlla ;=, Ndú;d l, yelsh’
· Operators iy Operands Ml;=ù fndfyda÷rg Expressions iEfohs’
Comments
j¾. 3 ls’
1’Single line comments (C++ style)
Ml ,hska Mlla mukla comment l,yelsh’
Comment ,hska Ml wdrïNfha ”// “ fhoSfuka Mla ,hska Mlla comment l,yelsh’
Eg; System.out.println("HelloWorld");// print Hello World on the screen
2’Multi line comments
,hska lsysmhla comment l,yelsh’
Comment ,hska Ml wdrïNfha “/* “ yd wjidkfha “*/” fhoSfuka ,hska lsysmhla comment l,yelsh’
Eg; System.out.println("HelloWorld");/*print Hello World
on the screen*/