
CSIS 110 โ Lecture 3
Turn in homework
Review
Project DisplayForecast.java
Key elements of the program
- three statements that display the quote
- method main()
oMethod is a named unit of code that performs some action
oEvery Java program must have a main() method
- Main() is a method of the class DisplayForecast
- Class defines the form of an object
oObjects have methods (behaviors)
oObjects may have attributes (data fields or values)
oClass has same name as its file (with same upper/lower case)
- What are comments for?
oComments are for people
oMany people look at programs โ comments are there to help these people
oComputer ignores the comments โ doesnโt affect how the program is
compiled.
- What is the purpose of indenting?
oImprove readability - indicate that statements are components of some
other program element (such as a method)
oLines are indented if they are a component of the preceding material.
oIndent consistently
- What is a keyword?
oKeywords are reserved words that have specific meanings in Java
oExamples: public, class, static, void
oIdentifiers are names we use to refer to methods, classes, variables
oIs main a keyword?
๏งmain is not a keyword โ it is an identifier (the name of a method).
- Who remembers what the identifier rules are?
oMust begin with alphabetic char, $, or _
oSubsequent chars: alpha, digit, $, or _
oAlpha includes foreign language chars such as pi.
oExamples
- What do the statements that start with 'System.out' do?
oSystem.out represents the standard output stream โ it is associated with the
console. System.out has methods print and println that cause their
parameters to be displayed.
oStatement invokes the method, causing the method to be executed โ i.e. it
performs its actions or behavior