.,,.,. 7. Sun Microsystems.,,. Sun Bill Joy.. 15... ( ), ( )... 4600.
.,,,,,., 5 Java 2 1.4. C++, Perl, Visual Basic, Delphi, Microsoft C#. WebGain Visual Cafe, Borland JBuilder, Sun ONE Studio., Sun Java 2 (Java 2 SDK). http://java.sun.com,, Java 2 21 -..,.? Java 2 21-3... 1.,,.,. 2.,,. 32
3.,,,,. 4,. 5. 6. 7. (Exception,, ). Sun Microsystems. 8, (Vector), (Stack), (Map), (Hash Table), (Bit Set). 9. (Swing). Java 2. 10 (,,,, ). 11.. 12.. 33
13. Java 2 Java2D. 14.,, Java 2. (JavaBeans), (JDBC). 15, (stream). 16.. 17 URL. 18..,,. 19. Microsoft Visual Basic. 20. (JDBC) JDBC-ODBC., Java 2 1.4 XML. 21. ( ) (HTML ). 34
,.,,, /.. http://www.java21days.com... Java 1.1 1.0 C++,,.....,,.. HTML, CGI Perl, 35
,, Java C C++,,....,.,. 3. 7,,.,.. 36
..,... http://www.java21days.com. 37
(Java) 1 1 2 3 4,, 5 6,, 7
IBM. IBM,. - PBS Robe rt X. Cring e ly 1995 S un Mic rosyste ms (Wo rld W ide We b)..,,,. J ava 2 2 1 -..
(Java) 5 Java 2 1.4. 2, NASA, IBM, Kaiser Permanente, ESPN,.,. JavaWorld Magazine, 1,700.,. 21..,.. (James Gosling) Sun C++(C, AT&T Bell (Bjarne Stroustrup) 10 ) 1990., C++. 42
C++. Sun, (World Wide Web). Sun 1995. Sun. C++( ), (Applet)., 6.. C++. C++, C C++,. (OOP, Object-oriented programming). (class),.,. (Platform neutrality). (interpreter), 43
(Java), (bytecode)., OS, Windows XP.., (w rite once, run anywhere).,., (, (write once, debug everywhere)).,..., C++..,..,.,... 44
A,.,. 21,,,,,.,,,.,,,. 1.4. Java 1.4 J, WebGain Visual Cafe, Sun One Studio, IBM VisualAge for Java.,.,,.. Sun http://java.sun.com (Java SDK, Java 2 Software Development Kit). Sun. Java 2 Software Development Kit, Standard Edition, Version 1.4. 45
(Java), Sun. SDK 1.4. (kit). Java SDK. B, Java 2...,..,,..., 1.,, 1. 46
.. (procedural programming)........,.....,,,,.... 47
(Java),,...,...,.,.. RS-232..... (instance), (instantiation).,. 48
com1 com2,. [ 1.1] ( ). 1.1 COM 1 ( ) COM 1 COM2... CommandButton. 3D 49
(Java) CommandButton. CommandButton, CommandButton.,,. CommandButton., CommandButton. javax.swing.j Button CommandButton. 9,.,.,..,.. Java 2 (Library), SDK 1.4. (Compiler). 50
,,,,,.,.... (Attribute) (Behavior). 1 VolcanoRobot. NASA Dante II. (Attribute). (, ).. -,, - -... 5 1
(Java) (instance variable).,. (object variable). ( )., VolcanoRobot....,.. (class variable). (class variable)... VolcanoRobot,... VolcanoRobot. 52
(Behavior).,,. VolcanoRobot. (Method). (Method)....., VolcanoRobot.,. 53
(Java). (instance method).. (class method).,,, VolcanoRobot... 2,.. [ 1.1], ( ) VolcanoRobot.java. 1.1 VolcanoRobot.java 1: cl ass Vol canorobot { 2: St r i ng st at us ; 3: i nt speed; 4: f l oat t emperat ure ; 5: 6: voi d checktemperat ure () { 7: i f (t emperat ure > 660){ 8: st at us = "r et ur ni ng home"; 9: speed = 5; 10: } 11: } 12: 13: void showattributes () { 14: Syst em.out.pr i nt l n ("St at us : " + st at us ); 54
15: Syst em.out.pr i nt l n ("Speed : " + speed ); 16: Syst em.out.pr i nt l n ("Temperat ure : " + t emperat ure ); 17: } 18: } [ 1.1] 1 VolcanoRobot. 1 ({) 18 (}). VolcanoRobot. 2 4. St r i ng st at us ; i nt speed; f l oat t emperat ure ; status, speed, temperature.. status,,, String. speed int. temperature float. String String. String. String. VolcanoRobot 6 11. 55
(Java) voi d checktemperat ure () { i f (t emperat ure > 660){ st at us = "r et ur ni ng home"; speed = 5; } }.,. checktemperature() [ 1.1] 6 11. VolcanoRobot. temperature 660,. status returning home., 5 ( ). showattributes() 13 17. voi d showat t r i but es () { Syst em.out.pr i nt l n ("St at us : " + st at us ); Syst em.out.pr i nt l n ("Speed :" + speed ); Syst em.out.pr i nt l n ("Temperat ure :" + t emperat ure ); } System.out.println(). VolcanoRobot. VolcanoRobot,. 56
VolcanoRobot. VolcanoRobot. VolcanoRobot (Application) main(), VolcanoRobot.. VolcanoRobot.java, ([ 1.1] 18 ).. publ i c st at i c voi d mai n (St r i ng [] argument s ) { Vol canorobot dant e = new Vol canorobot (); dante.status = "exploring"; dant e.speed = 2; dant e.t emperat ure = 510; } dant e.showat t r i but es (); Syst em.out.pr i nt l n ("I ncreasi ng speed t o 3. " ); dant e.speed = 3; dant e.showat t r i but es (); Syst em.out.pr i nt l n ("Changi ng t emperat ure t o 670. " ); dante.t emperature = 670; dant e.showat t r i but es (); Syst em.out.pr i nt l n ("Checki ng t he t emperat ure. " ); dant e.checktemper at ur e (); dant e.showat t r i but es (); main() VolcanoRobot. VolcanoRobot.java. SDK. 57
(Java) VolcanoRobot.java. (command line). j avac Vol canorobot.j ava [ 1.2] VolcanoRobot.java. SDK 1.4 http :// www.java21days.com. 1.2 VolcanoRobot.java 1: cl ass Vol canorobot { 2: St r i ng st at us ; 3: i nt speed; 4: f l oat t emperat ure ; 5: 6: voi d checktemperat ure () { 7: i f (t emperat ure > 660){ 8: st at us = "r et ur ni ng home"; 9: speed =5; 10: } 11: } 12: 13: void showattributes () { 14: Syst em.out.pr i nt l n ("St at us : " + st at us ); 15: Syst em.out.pr i nt l n ("Speed :" + speed ); 16: Syst em.out.pr i nt l n ("Temperat ure :" + t emperat ure ); 17: } 18: 19: publ i c st at i c void main(st ring [] argument s ) { 20: Vol canorobot dant e = new Vol canorobot (); 21: dante.status = "exploring"; 58
22: dant e.speed = 2; 23: dant e.t emperat ure = 510; 24: 25: dant e.showat t r i but es (); 26: Syst em.out.pr i nt l n ("I ncreasi ng speed t o 3. " ); 27: dant e.speed = 3; 28: dant e.showat t r i but es (); 29: Syst em.out.pr i nt l n ("Changi ng t emperat ure t o 670. " ); 30: dante.t emperature = 670; 31: dant e.showat t r i but es (); 32: Syst em.out.pr i nt l n ("Checki ng t he t emperat ure. " ); 33: dant e.checktemper at ur e (); 34: dant e.showat t r i but es (); 35: } 36: } VolcanoRobot. VolcanoRobot.class SDK VolcanoRobot. j ava Vol canorobot VolcanoRobot. St at us :expl or i ng Speed :2 Temperat ure :510. 0 I ncreasi ng speed t o 3. St at us :expl or i ng Speed :3 Temperat ure :510. 0 Changing temperat ure to 670. St at us :expl or i ng Speed :3 Temperat ure :670. 0 59
(Java) Checking the temperat ure. Status :returning home Speed :5 Temperat ure :670. 0 [ 1.2] main(). 19 - main(). main(). 5,. static. main(). 20 - VolcanoRobot,. dante. 2 1 23 - dante. status exploring, speed 2, temperature 510. 25 - dante showattribute(). status, speed, temperature. 26 - System.out.println(). 27 - speed 3. 30 - temperature 670. 33 - checktemperature() dante. temperature 660. status speed.,,. 60
.,. (Inheritance).....,. (subclass ), (s uperclass).,..,.., (hierarchy).. 6 1
(Java),,,.,. [ 1.2]. 1.2 A B. B A. B C, D, E. C, D, E B. Object.. Object,..,.., CommandButton., CommandButton CommandButton. CommandButton 62
CommandButton. CommandButton.. (s ubclass ing).., Object.. (class definition) Object. VolcanoRobot Object...,..,..,., ( ). 63
(Java) VolcanoRobot,., MarsRobot..., VolcanoRobot.java MarsRobot.java., MarsRobot VolcanoRobot. VolcanoRobot MarsRobot., MoonRobot, UnderseaRobot, DesertRobot?. Object. Robot.,. Robot,,. Robot WalkingRobot DrivingRobot. WalkingRobot, DrivingRobot.,,.. [ 1.3].,. WalkingRobot (ScienceRobot, GuardRobot, SearchRobot )., TwoLegged FourLegged Robot. 64
1.3 Robot VolcanoRobot. VolcanoRobot Object Robot WalkingRobot, ScienceRobot.,,?. Robot temperature....,.. 65
(Java) 1.4 Robot Robot.,,..,,.... (interpreter).,. [ 1.5].,,...,,. (overriding) ([ 1.6] ). 66
1.5,. 1.6.,. 67
(Java) (single inheritance) (, ). C++ 1,. (multiple inheritance),.,..,., (branch). (interface). (interface),..., Comparable... 6,,,. 68
(package).,.. java. java,. java,,., Sun. java.lang., (import).., Color java.awt Color java.awt.color., 1,.. OOP 20. 1,,,.,.. 2. 1. 69
(Java) (Class ) -.. (Object) -.,. (Instance) -.. (Method) -. (function),. (Class Method) - (Instance method) -.. (Class variable) - (Instance variable) - (Interface) - (Package) -. java.lang (import). (Subclass) -. (subclassing).. (Superclass ) -.,. 70
Q&A, (function),? (C++ (member function) ).., method.? ( ).., Java.lang Math PI.., PI., String String length()., length(). 1.. 71
(Java) 1. (Class)? (Object) (Template) (Instance) 2.?. 3.? 1. (Template). 2...,. 3... 72
. 1.?.... http://www.java21days.com. [Day 1] [Certification Practice]. 1. VolcanoRobot main() virgil VolcanoRobot,..,,,. http://www.java21days.com. 73