Introduktion till Java Modul 1 Objektets delar Fält Metoder Olika sorters metoder Constructors Destructors Mutators (transformers) Accessors (Predicates) 1 Klasser och objekt klass objekt C++ vs. Java C++ Java main() main() 2 Traditionellt API vs. Java API Traditionellt Applikation Språk Operativsystem Hårdvara Med Java Applikation Java Java Virtual Machine (JVM) Operativsystem Hårdvara Standardiserade filnamn <N am n>.java K ällkod <N am n>.class B yteko d Java V irtual M ach ine 3 http://java.sun.com Kodningskonventioner http://java.sun.com/docs/codeconv/ – – – 80% of the lifetime cost of a piece of software goes to maintenance. Hardly any software is maintained for its whole life by the original author. Code conventions improve the readability of the software, allowing engineers to understand new code more quickly and thoroughly. Referenser till objekt Java: ett sätt objReference attr1 method1() objReference.attr1 objReference.method1() objName.attr1 objName.method1() C++: tre sätt ! objPointer objName objReference attr1 method1() (*objPointer).attr1 (*objPointer).method1() objReference->attr1 objReference->method1() 4