Survey
* Your assessment is very important for improving the workof artificial intelligence, which forms the content of this project
* Your assessment is very important for improving the workof artificial intelligence, which forms the content of this project
/**
Author:
Date:
Language Version:
Course:
Section:
File Name:
Classes:
Description:
JChildress
2-12-07
Java2 1.5.0_06
CS1043
1
Hello.java
Hello
This program demonstrates how to
output a message.
*/
public class Hello
{
public static void main( String[] args )
{
System.out.printf( "Hello students.\n" );
}
}
// end of class Hello
General Statements about the Java programming language:
A Java program consists of blocks of program statements
organized into classes and methods. Classes and methods
consist of a
o header line
o body of code. The body of code is enclosed in a
matching set of (curly) braces { … }
Braces must be in matching pairs.
Braces can be nested.
Program statements end with a semicolon ;
Header lines do not end with a semicolon
Java is a free-form language. This means that the amount of
empty space and new lines between operators, keywords,
identifiers, classes, and methods is adjustable by the
programmer. Example:
public class Hello{public static void main(String[]
args){System.out.printf("Hello students.\n")}}
Java allows for annotations (aka comments) from the
programmer using the // character sequence and the /*, */
character sequences. The compiler ignores all statements
from the // to the end of the current line. The /*, */
combination is used to create a block of annotations.
Everything between these character sequences is ignored by
the compiler.
Java is case sensitive: Hello is different from hello.
The Java compiler is javac. It is used to find the syntax
errors and convert the source into byte code.
The Java interpreter is known as java. It is used to
execute the statements using a computer. The Java
interpreter is the Java Virtual Machine.
Java programs are in files that have a program name prefix
followed by the suffix .java
o
Our example is Hello.java