Beruflich Dokumente
Kultur Dokumente
@saeid
http://about.me/saeid
saeid.zebardast@gmail.com
1
Please Please Please
Ask Questions
As Much As You Like
• This is not a lecture!
‣ Better ways
‣ Best practices
‣ My mistakes!
Introduction
• What’s Java?
- Since 1995
- Base on C/C++
• License Issue
- What’s OpenJDK?
3
JVM
Java Principles
1. Simple
2. Secure
- No explicit pointer.
3. Object Oriented
4. Robust
- Machine independent.
6. Portable
7. High Performance
8. Multithreaded
9. Distributed
- URL class allows a Java application to open and access remote objects on the internet.
Java History
• JDK 1.0 (January 21, 1996)
7
Java Uses
• Desktop, Web-based and Mobile Apps
- Android
- LibreOffice (OpenOffice)
• Embedded Systems
• Big Data
8
Installation
• Just enter the following command:
- $ java -version
- $ javac -version
9
Java Syntax
• Data Types
• Variables
• Operators
• Statements
10
Data Types
• Primitives
• Objects
11
Primitive Data Types
Integer
Type Min Max 2^
- String
- Date
- Person, Shape
15
Variables
• type identifier [=value];
- boolean status;
- int i = 0;
- String name;
16
Operators
Type operators
Arthimetic +, -, *, /, %
17
Select Statements
• () ? : ;
• if () {}
• if () {} else {}
• if () {} else if {} else {}
• switch () {
case X: ; break;
case Y: ; break;
default : ;
}
18
Iteration Statements
• while () {}
• do {} while ();
• for () {}
19
Syntax
Comments
• /* This is a multi-line comment.
It may occupy more than one line. */
• Java Docs
• /**
* This is a documentation comment.
*
* @author Saeid Zebardast
*/
Access modifiers
Extended Class Non-extended
Same class or Other class inside inside another
Modifier inside another
nested class the same package package
package
private yes no no no
default
yes yes no no
(package private)
• Inner class
• Local class
- class Foo {
void bar() {
class Foobar {// Local class within a method
}
}
}
• Initialization
- class Foo {
// class members
}
• Overriding methods
- class Operation {
public int doSomething() {
return 0;
}
}
[import _________]
[import _________]
[import _________]
class Bar {
//class members
}
Simple Exercise
Hello Word!
• Create HelloWorldApp.java:
- public class HelloWorldApp {
public static void main(String[] args) {
System.out.println("Hello World!"); // Print the string to the console.
}
}
• Compile:
- $ javac HelloWorldApp.java
• Run:
- $ java HelloWorldApp
28
Read The F* Manual
• RTFM
- http://docs.oracle.com/javase/
- http://docs.oracle.com/javase/tutorial/
reallybigindex.html
29
Thank You