techniques of java programming
play

Techniques of Java Programming Manuel Oriol, April 5th, 2006 - PowerPoint PPT Presentation

Techniques of Java Programming Manuel Oriol, April 5th, 2006 Software Engineering Goal Teach Java to proficient programmers Teach basics and also advanced features Have people read research articles and specifications Software


  1. Techniques of Java Programming Manuel Oriol, April 5th, 2006 Software Engineering

  2. Goal • Teach Java to proficient programmers • Teach basics and also advanced features • Have people read research articles and specifications Software Engineering

  3. Roadmap • Java Basics • Eclipse • Threads and synchronization • Class loading and reflection • Java Virtual Machines • Byte-Code and Just-In-Time compilation • Java Middleware • Java Components and more... Software Engineering

  4. Modus Operandi • Assistants: Dr. Lisa Ling, Till G. Bay, Andreas Leitner • Lectures: - 2 hours lectures on Thursday - 1 hour exercise on Wednesday • Exercises will be corrected in the exercise lectures, not graded • Written exam: 60% of the grade • Project: 40% of the grade Software Engineering

  5. Documents • Slides - Web • Course Abstract - Printed... • Articles/Reading material - Web links Software Engineering

  6. Java Basics: Part 1 - Java Tools Manuel Oriol, April 5th, 2006 Software Engineering

  7. Java • O–O language • multi-platform • type-safe • class-based • imperative Software Engineering

  8. The Big Picture Documentation Source Code Documentation Generator .java javadoc .html javac .class java Byte Code, Virtual Compiler Program Machine Software Engineering

  9. Environment Variables • PATH • CLASSPATH Software Engineering

  10. Java Compiler • javac *.java • arguments are files with extension .java • each class has a .class file • options: -g for debugging -verbose -cp for classpath -d for output directory Software Engineering

  11. Java Virtual Machine (JVM) • java MyMain • arguments is a class name containing main method • each class loaded on-demand • options: -verbose -cp for classpath -d for output directory Software Engineering

  12. Java Documentation • javadoc *.java • comments /** */ and // • options: -verbose -cp for classpath -d for output directory Software Engineering

  13. Java Archive • jar cvf classes.jar *.class • first argument is the target is option f • each class loaded on-demand • options: c create the archive v verbose mode f first argument is target file name x extract archive Software Engineering

  14. Java Debugger • jdb MyMain • commands during execution: stop at MyMain:25 stop in MyMain.myMehtod next step run print Software Engineering

  15. Java Basics Part 2 - Language Manuel Oriol, April 5th, 2006 Software Engineering

  16. Hello World! public class HelloWorld { public static void main(String[] args){ System.out.println("Hello World!"); } } Software Engineering

  17. Packages • Package Names: general.lessGeneral.precise • Defines a directory infrastructure • Fully Qualified Name Software Engineering

  18. Primitive Types • Primitive types: int, byte, char, long, short, boolean • comparisons: <,>,==,>=,<=, != • operators: +, -, *, / • Equivalent classes: Integer, Byte, Character, Long, Short, Boolean Software Engineering

  19. Reference Types • Classes • Generic classes • Interfaces Software Engineering

  20. Class • abstract public abstract class MyClass{ • final • public } Software Engineering

  21. Interfaces • Only signature of methods • has to be implemented in classes public interface MyInterface{ ... } Software Engineering

  22. Inheritance • Single inheritance • implementation of interfaces to simulate multiple inheritance public class MyClass extends Object implements MyInterface{ } Software Engineering

  23. Arrays • Type [] • Declared when using variables Software Engineering

  24. Generic Classes • Classes dependent on another class • (Will come back to this) public class MyClass < E >{ } Software Engineering

  25. Variables • Local Variables • Instance Variables • Class Variables Software Engineering

  26. Local Variable • Declared in the code (no matter the location) • Local to the current block ({}) • Must be initialized before using them int a; int b=3; MyClass c; String s=”Hello World!”; Software Engineering

  27. Instance Variables • Declared the same way as local variables but outside any method • final, transient, volatile • Visibility: public int a; private int b=3; • public MyClass c; • protected protected String s=”Hello • default World!”; • private Software Engineering

  28. Class Variables • As instance variables but with static • shared by all instances Software Engineering

  29. this • refers to the current object Software Engineering

Recommend


More recommend