• Identifiers
  • Reserved Words
  • White Space
  • Programming Language Levels
  • Programming Languages
  • Chapter 1: Computer Systems




    Download 225,5 Kb.
    bet8/10
    Sana22.07.2024
    Hajmi225,5 Kb.
    #268238
    1   2   3   4   5   6   7   8   9   10
    Bog'liq
    slides01

    Comments

    • 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 end of the line
    • /* 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

    • The Java 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

    Download 225,5 Kb.
    1   2   3   4   5   6   7   8   9   10




    Download 225,5 Kb.