Structure of Java Program
Structure of Java Program
Structure of Java Program
• The JVM’s class loader takes the .class files containing the program’s
bytecode and transfers them into main memory
• It also loads any of the .class files provided by Java that your program uses.
• Bytecode Verifier examines bytecodes to ensure that they’re valid and
do not violate Java’s security restrictions.
• Java enforces strong security to make sure that Java programs arriving over the
network do not damage your files or your system (as computer viruses and
worms might)
JIT Compiler (1 of 2)
• The keyword class is used to declare that a new class is being defined.
• HelloWorldApp is an identifier that is the name of the class.
• The entire class definition, including all of its members, will be
between the opening curly brace ({) and the closing curly brace (}).
• The use of the curly braces in Java is identical to the way they are used
in C, C++.
• In Java, all program activity occurs within class. This is one reason why
all Java programs are object-oriented.
Description
• Whitespace
• Java is a free-form language.
• For example, the program could have been written all on one line or in any
other strange way you felt like typing it.
• In Java, whitespace is a space, tab, or newline.
• Identifiers
• Identifiers are used for class names, method names, and variable names.
• An identifier may be any descriptive sequence of uppercase and lowercase
letters, numbers, or the underscore and dollar-sign characters.
• They must not begin with a number.
• Java is case-sensitive, so VALUE is a different identifier than Value.
• Some examples of valid identifiers are:
• AvgTemp, count, a4, $test, this_is_ok
• Invalid variable names include:
• 2count, high-temp, Not/ok
Lexical Issues
• Literals
• A constant value in Java is created by using a literal representation of it. For
example, here are some literals:
• 100, 98.6, ‘X’, “This is a test”
• A literal can be used anywhere a value of its type is allowed.
• Comments
• There are three types of comments defined by Java. You already know two:
single-line and multiline. The third type is called a documentation comment.
• The documentation comment begins with a /** and ends with a */.
• Separators
• In Java, there are a few characters that are used as separators.
• The most commonly used separator in Java is the semicolon.
Lexical Issues
Lexical Issues
• The keywords const and goto are reserved but not used.
Java Class Libraries
Any Questions?