|
Chapter 1: Computer Systems
|
bet | 8/10 | Sana | 22.07.2024 | Hajmi | 225,5 Kb. | | #268238 |
Bog'liq slides01Comments - Comments in a program are also called inline documentation
- They should be included to explain the purpose of the program and describe processing steps
- They do not affect how a program works
- Java comments can take two forms:
- /* this comment runs to the terminating
- symbol, even across line breaks */
Identifiers - Identifiers are the words a programmer uses in a program
- An identifier can be made up of letters, digits, the underscore character (_), and the dollar sign
- They cannot begin with a digit
- Java is case sensitive, therefore Total and total are different identifiers
Identifiers - Sometimes we choose identifiers ourselves when writing a program (such as Lincoln)
- Sometimes we are using another programmer's code, so we use the identifiers that they chose (such as println)
- Often we use special identifiers called reserved words that already have a predefined meaning in the language
- A reserved word cannot be used in any other way
Reserved Words - abstract
- boolean
- break
- byte
- byvalue
- case
- cast
- catch
- char
- class
- const
- continue
- default
- do
- double
- else
- extends
- false
- final
- finally
- float
- for
- future
- generic
- goto
- if
- implements
- import
- inner
- instanceof
- int
- interface
- long
- native
- new
- null
- operator
- outer
- package
- private
- protected
- public
- rest
- return
- short
- static
- super
- switch
- synchronized
- this
- throw
- throws
- transient
- true
- try
- var
- void
- volatile
- while
White Space - Spaces, blank lines, and tabs are collectively called white space
- White space is used to separate words and symbols in a program
- Extra white space is ignored
- A valid Java program can be formatted many different ways
- Programs should be formatted to enhance readability, using consistent indentation
- See Lincoln2.java and Lincoln3.java
Programming Language Levels - There are four programming language levels:
- machine language
- assembly language
- high-level language
- fourth-generation language
- Each type of CPU has its own specific machine language
- The other levels were created to make it easier for a human being to write programs
Programming Languages - A program must be translated into machine language before it can be executed on a particular type of CPU
- This can be accomplished in several ways
- A compiler is a software tool which translates source code into a specific target language
- Often, that target language is the machine language for a particular CPU type
- The Java approach is somewhat different
|
| |