Download presentation
Presentation is loading. Please wait.
Published byBlaze Garrett Modified over 9 years ago
3
Comments are for people Header comments supply basic information about the artifact
4
Comments also used to describe class elements
5
Whitespace is also for people Blank lines make elements stand out
6
Indentation is a form of whitespace Indentation is used to indicate that what follows is a part of what proceeded
7
Indentation is a form of whitespace Indentation is used to indicate that what follows is a part of what proceeded
8
Keywords are reserved lowercase words that have special meaning public – what follows is shareable class – program or object definition static – not part of an object definition void – method does not return a value
9
Name of the class A Java name must be an identifier Java has syntax rules for stating what is a valid name; e.g., identifiers begin with letter and can be followed letters and numerals
10
To encourage program understanding style rules give name understanding Convention to capitalize the first letter in a class name General convention to capitalize successive words in a name
11
PrintQuote, main, String, args, System, out, and println are all names Convention that identifiers not indicating a class begin with a lower case letter
12
Braces delimit a class definition
13
Braces delimit a block of code
14
A program begins executing the code in method main() Method main() must be public, static, and void
15
Every method has a parameter list following its name. The list is contained with a pair of parentheses. For some methods, the list is empty
16
Method main() takes a single parameter of type String[] Everybody who is anybody calls that parameter, args
17
Following the parameter list is the body of the method The method body lists the statements (i.e., actions) it is to perform when invoked (started up)
18
The statements are performed from top to bottom
20
Because statements are allowed in general to span multiple lines an indicator is needed for separating statements from one another Java statements are terminated with a semicolon
21
The dot is the selection operator
22
Sometimes multiple selecting is needed to get a hold of the desired component
23
System is the name of a class library whose elements are automatically available to a program
24
The System library has an element named out out represents an object configured to be associated with your display
25
out has a println() behavior println() is a method println() displays text to its display
26
println() displays the value of its argument
27
This use of println() says to print the literal string ”I’m never going to the Louvre again.” to its display A literal string is a sequence of characters within a pair of the double-quote characters
28
This use of println() says to print the literal string ”-- Joanne Cohoon” to its display
29
A program terminates when all of the statements in method main() are completed
Similar presentations
© 2024 SlidePlayer.com. Inc.
All rights reserved.