CMPT 125: Lecture 2 Introduction To Java
CMPT 125: Lecture 2 Introduction To Java
Introduction to Java
Tamara Smyth, [email protected]
School of Computing Science,
Simon Fraser University
January 3, 2009
1
Brief History of Java
PROGRAM CODE:
/*
* WiseWords.java CMPT 125 Sample code
* (by Toby Donaldson)
*/
OUTPUT:
String[] args
1
This is not generally true of all methods. Methods may have several input parameters, or alternatively,
none at all.
/*
This is a longish comment that spans multiple
lines. Comments in this form can provide a
good deal of information about the code. You
may consider using this comment style to head
your code, providing details of authorship,
when and where the code was written, and perhaps
even for what purpose---such as a CMPT 125
assignment!
*/
can
make a program
easier to
read and
understand!
• Editors:
– The tool with which you write and edit your
programs. Familiarity, with your editor can greatly
increase the speed at which you write and edit
programs.
• Compiler:
– The program that translates code in one language,
the source code, to equivalent code in another
language, the target code.
– For many traditional compilers, the source code is
translated directly to machine language.
• Interpreter:
– Similar to a compiler, but combines the translation
and execution activities, eliminating a separate
compilation phase.
– One small part of code, such as a code statement,
is translated and executed at a time, making it run
more slowly.