|
In a natural language, the next logical step above the parts of speech are
sentences. English has the following:
|
Types of Sentences
Declarative
Interrogative
Imperative
Exclamatory
| | | |
|
|
|
In Java, the analogue of a sentence is a statement.
|
Java Statements
| Packaging
| packagepackage mypackage; |
importimport java.io.*;
import mypackage.MyClass; |
| | Declarative
| class/ interface
public class MyClass { ... }
public interface MyInterface { ... } |
methodspublic void aProcedure(){ ... } |
variablesint anInt |
| | Executable
| assignmenta=b+d(e);
c+=g;
f--; |
method invocationaProcedure(); |
| | Control
| sequence/ block{ s1; s2; s3; } |
conditional/ selectionif statement
switch statement |
iterationfor statement
while statement
do statement |
exceptiontry statement |
interruptreturn statement
throw statement |
|
| | | | | | | | | | | |
|
|