CS242 Advanced Programming Concepts in Java - PowerPoint PPT Presentation

1 / 35
About This Presentation
Title:

CS242 Advanced Programming Concepts in Java

Description:

Documentation comments: used by javadoc to generate info for users of your classes ... A file can contain more than one class definition, but only one can be public. ... – PowerPoint PPT presentation

Number of Views:336
Avg rating:3.0/5.0
Slides: 36
Provided by: janicets
Category:

less

Transcript and Presenter's Notes

Title: CS242 Advanced Programming Concepts in Java


1
CS242Advanced Programming Concepts in Java
  • Fall 2007
  • Prof. Searleman
  • jets_at_clarkson.edu

2
Announcements
  • Activities Fair Wednesday night!
  • 700 to 800 pm in Cheel arena
  • CS labs ITL, COSI VRLab
  • ACM and ACM SIGGRAPH IDEA

3
CS242
  • Objectives of this course
  • Administrivia
  • Overview of Java
  • A Brief History of Java
  • Introduction to Java technology
  • Getting started Compiling running your first
    Java program

4
Course Objectives
  • Students will learn advanced programming concepts
    and modern programming techniques. These will
    include object-oriented design and design
    patterns, graphical user interface design, event
    models, exception handling, multithreading,
    network programming, and the client/server
    paradigm.
  • Students will learn the Java programming language
    and core APIs, the Java Virtual Machine (JVM),
    and Java Foundation Classes (JFC/Swing)

5
Administrivia
  • course webpage
  • http//www.clarkson.edu/jets/cs242/fa07
  • contact info
  • office SC375 (also VR Lab, SC336)
  • phone 268-2377,
  • email jets_at_clarkson.edu,
  • IM jetsza

6
Textbooks
  • Object-Oriented Design Patterns, Second
    Edition, by Cay Horstmann, John Wiley Sons,
    ISBN 0-471-74487-5, 2006.
  • Effective Java Programming Language Guide, Joshua
    Bloch, Addison-Wesley/Benjamin-Cummings,
  • ISBN 0-201-31005-8, 2001

7
Other References (on-line)
  • Beginning Java2 JDK 5 Edition, Ivor Horton,
    Wiley, ISBN 0-7645-6874-4, 2005 (note this is
    available on-line to any member of the ACM)
  • Thinking in Java, 4th Edition, Bruce Eckel,
    Prentice Hall, ISBN 0-13-187248-6, 2006
    (http//www.bruceeckel.com)

8
Grading Policy
  • 35 2 Midterm Exams
  • (tentatively 10/11 11/13)
  • 30 Final Exam
  • 35 Programming Projects
  • Homework

9
On-line Resources
  • http//www.clarkson.edu/jets/cs242/fa07/onlineres
    ources.html
  • Compiling, running debugging
  • Java tutorials documentation
  • Java source
  • UML, design patterns, etc.

10
A Brief History of Java
  • Sun Microsystems - 1991
  • James Gosling - Oak
  • Pat Naughton (Clarkson alum, CS) X11
  • Mike Sheridan
  • Bill Joy
  • and others

11
Why Java?
plus security, networking, multithreading, web
programming, and so on
12
Java Virtual Machine (JVM) write once, run
anywhere
13
(No Transcript)
14
Java Technology
15
Java Technology What is Java?
  • programming language
  • object-oriented, architecture independent,
    distributed, multithreaded
  • syntax similar to C/C
  • concepts similar to Smalltalk
  • collection of APIs (Application Programming
    Interface)
  • java.lang automatically imported into Java
    programs
  • java.util useful utility classes (e.g. Date)
  • java.io Input/Output classes
  • java.awt windowing classes
  • javax.swing Java Foundation classes (JFC/Swing)
  • java.net networking classes
  • standard extension APIs for enterprise, security,
    etc.

16
Example java program
  • // From TIJ by Bruce Eckel
  • import java.util.
  • public class HelloDate
  • public static void main(String args)
  • System.out.println("Hello, it's ")
  • System.out.println(new Date())

source file HelloDate.java
All code must be inside a named class the
filename must match the classname exactly
(case-sensitive)
17
Deconstructing a Java program
  • // From TIJ by Bruce Eckel
  • //
  • / /
  • / /

18
Deconstructing a java program
  • // From TIJ by Bruce Eckel
  • import java.util.
  • public class HelloDate
  • public static void main(String args)
  • System.out.println("Hello, it's ")
  • System.out.println(new Date())

Never import the java.lang API it is always
automatically imported
19
Deconstructing a java program
  • // From TIJ by Bruce Eckel
  • import java.util.
  • public class HelloDate

A file can contain more than one class
definition, but only one can be public.
20
Deconstructing a Java program
  • // From TIJ by Bruce Eckel
  • import java.util.
  • public class HelloDate
  • public static void main(String args)

The main program must have this exact header
public the main method is publicly visible
static allows the main program to be called
without creating an object (details to follow)
void no value is returned
String array of Strings allows info to be
given to the main program ( String args is also
OK )
21
Deconstructing a java program
  • // From TIJ by Bruce Eckel
  • import java.util.
  • public class HelloDate
  • public static void main(String args)
  • System.out.println("Hello, it's ")

Prints a string to the standard output stream
System is a java class
out is an instance of an OutputStream defaults
to the console
22
Deconstructing a java program
  • // From TIJ by Bruce Eckel
  • import java.util.
  • public class HelloDate
  • public static void main(String args)
  • System.out.println("Hello, it's ")
  • System.out.println(new Date())

Also prints a string to standard output, in this
case the current date and time (must interact
with the operating system to get this info)
This new object is created on-the-fly since it
is no longer needed after this line, it is
subject to garbage collection
23
Example java program
  • // From TIJ by Bruce Eckel
  • import java.util.
  • public class HelloDate
  • public static void main(String args)
  • System.out.println(
  • "Hello, it's " new Date() )

source file HelloDate.java
println only can have 1 string argument, so can
concatenate strings with
24
Compiling Running a Java Program
  • Step 1 compile into bytecodes
  • javac HelloDate.java
  • Step 2 run
  • java HelloDate

25
Compiling Running a Java Program
  • Step 1 compile into bytecodes
  • javac HelloDate.java

26
Compiling Running a Java Program
  • Step 2 run
  • java HelloDate

27
Demo
  • run HelloDate on IBM laptop under Windows
  • run HelloDate on laptop using TextPad
  • show javadoc for Java 1.5

28
Exercise
  • Visit java.sun.com, download install Java 2 SDK
    (JDK 6u1) plus documentation
  • Download and install editor/IDE of your choice
    (Eclipse, NetBeans, Ant, TextPad, Jedit,
    whatever)
  • Visit java.sun.com tutorials read Your first
    cup of Java and Getting Started
  • Read Chapter 1 of Horstmann and Chapter 1 of
    Effective Java

Complete this assignment before class on Thursday
(preferably) or no later than Friday.
29
Object-Oriented Programming
  • key idea dynamic objects interact by sending
    messages to each other how something is done
    depends on who is asked to do it
  • OOP languages Simula, Smalltalk, C,
    Lisp/Scheme, Java, C, etc.

30
Key Terms

31
Example drawing program
  • Standard engineering design
  • vs.
  • Object-Oriented design

32
Main ideas of OOP
  • Encapsulation keep classes separated and prevent
    them from having to know too much about each
    other (hide the implementation)
  • Inheritance reuse code

33
Java Basics
  • Everything (except a primitive) is an object
  • An object has an interface

34
  • Consider the following perspectives
  • Class designer/implementer
  • - designs implements a class
  • vs.
  • Client programmer
  • - uses a class for an application
  • vs.
  • End-user
  • - uses the application

35
Die Class
  • how to represent?
  • what is a good interface?
Write a Comment
User Comments (0)
About PowerShow.com