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

techniques of java programming
SMART_READER_LITE
LIVE PREVIEW

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


slide-1
SLIDE 1

Software Engineering

Techniques of Java Programming

Manuel Oriol, April 5th, 2006

slide-2
SLIDE 2

Software Engineering

Goal

  • Teach Java to proficient programmers
  • Teach basics and also advanced features
  • Have people read research articles and

specifications

slide-3
SLIDE 3

Software Engineering

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...

slide-4
SLIDE 4

Software Engineering

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
slide-5
SLIDE 5

Software Engineering

Documents

  • Slides - Web
  • Course Abstract - Printed...
  • Articles/Reading material - Web links
slide-6
SLIDE 6

Software Engineering

Java Basics: Part 1 - Java Tools

Manuel Oriol, April 5th, 2006

slide-7
SLIDE 7

Software Engineering

Java

  • O–O language
  • multi-platform
  • type-safe
  • class-based
  • imperative
slide-8
SLIDE 8

Software Engineering

The Big Picture

.java .class .html

javac javadoc java

Virtual Machine Compiler Documentation Generator Byte Code, Program Source Code Documentation

slide-9
SLIDE 9

Software Engineering

Environment Variables

  • PATH
  • CLASSPATH
slide-10
SLIDE 10

Software Engineering

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
slide-11
SLIDE 11

Software Engineering

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
slide-12
SLIDE 12

Software Engineering

Java Documentation

  • javadoc *.java
  • comments /** */ and //
  • options:
  • verbose
  • cp for classpath
  • d for output directory
slide-13
SLIDE 13

Software Engineering

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

slide-14
SLIDE 14

Software Engineering

Java Debugger

  • jdb MyMain
  • commands during execution:

stop at MyMain:25 stop in MyMain.myMehtod next step run print

slide-15
SLIDE 15

Software Engineering

Java Basics Part 2 - Language

Manuel Oriol, April 5th, 2006

slide-16
SLIDE 16

Software Engineering

Hello World!

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

slide-17
SLIDE 17

Software Engineering

Packages

  • Package Names: general.lessGeneral.precise
  • Defines a directory infrastructure
  • Fully Qualified Name
slide-18
SLIDE 18

Software Engineering

Primitive Types

  • Primitive types: int, byte, char, long, short,

boolean

  • comparisons: <,>,==,>=,<=, !=
  • operators: +, -, *, /
  • Equivalent classes: Integer, Byte, Character,

Long, Short, Boolean

slide-19
SLIDE 19

Software Engineering

Reference Types

  • Classes
  • Generic classes
  • Interfaces
slide-20
SLIDE 20

Software Engineering

Class

  • abstract
  • final
  • public

public abstract class MyClass{ }

slide-21
SLIDE 21

Software Engineering

Interfaces

  • Only signature of methods
  • has to be implemented in classes

public interface MyInterface{ ... }

slide-22
SLIDE 22

Software Engineering

Inheritance

  • Single inheritance
  • implementation of interfaces to simulate

multiple inheritance public class MyClass extends Object implements MyInterface{ }

slide-23
SLIDE 23

Software Engineering

Arrays

  • Type []
  • Declared when using variables
slide-24
SLIDE 24

Software Engineering

Generic Classes

  • Classes dependent on another class
  • (Will come back to this)

public class MyClass < E >{ }

slide-25
SLIDE 25

Software Engineering

Variables

  • Local

Variables

  • Instance

Variables

  • Class

Variables

slide-26
SLIDE 26

Software Engineering

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!”;

slide-27
SLIDE 27

Software Engineering

Instance Variables

  • Declared the same way as local variables but
  • utside any method
  • final, transient, volatile
  • Visibility:
  • public
  • protected
  • default
  • private

public int a; private int b=3; MyClass c; protected String s=”Hello World!”;

slide-28
SLIDE 28

Software Engineering

Class Variables

  • As instance variables but with static
  • shared by all instances
slide-29
SLIDE 29

Software Engineering

this

  • refers to the current object