Beruflich Dokumente
Kultur Dokumente
Java Programming
Introduction
– Java applications and applets
– Primitive data types
– Java control flow
– Methods
– Object-oriented programming
Fundamentals of Programming
– Introduction to Java
– Primitive Data Types and Operations
– Control Statements
– Methods
Introduction to Java
What Is Java?
Getting Started With Java Programming
– Compiling and Running a Java Application
What Is Java?
History
Characteristics of Java
History
James Gosling
Oak
Java Source
File
Compiler
Bytecode
Executing Applications
On command line
– java classname
Bytecode
java Welcome
output:...
Primitive Data Types and Operations
Identifiers,
Variables, and Constants
Primitive Data Types
– Byte, short, int, long, float, double, char, boolean
Operators
– +, -, *, /, %, +=, -=, *=, /=, %=, ++, --
Expressions
Styleand Documentation
Syntax Errors, Runtime Errors, and Logic Errors
Numerical Data Types
byte 8 bits
short 16 bits
int 32 bits
long 64 bits
float 32 bits
double 64 bits
Control Statements
SelectionStatements
–Using if and if...else
–Nested if Statements
–Using switch Statements
–Conditional Operator
Repetition Statements
–Looping: while, do, and for
–Nested loops
–Using break and continue
Selection Statements
if Statements
switch Statements
Conditional Operators
if Statements
if (booleanExpression)
{
statement(s);
}
Example:
if ((i >= 0) && (i <= 10))
{
System.out.println("i is an “ +
“integer between 0 and 10");
}
The if...else Statement
if (booleanExpression)
{
statement(s)-for-the-true-case;
}
else
{
statement(s)-for-the-false-case;
}
Repetitions
while Loops
do Loops
for Loops
break and continue
Introducing Methods
Method Structure
A method is modifier methodName
of method
heading
public static int max(int num1, int num2)
{
statements method
int result = 0;
perform an }
return value
operation.
Declaring Methods