Java Fundamentals Tutorial

NewCircle's Java Fundamentals Tutorial

Aleksandar Gargenta


1. Overview of Java

Introduction to Java Development

1.1. History of Java

1991

Stealth Project for consumer electronics market (later Green Project)

Language called Oak then renamed to Java

1993

First Person Project for set-top boxes

1994

LiveOak Project for new OS

HotJava Web Browser

1995

Sun formally announces Java at SunWorld

Netscape incorporates support for Java – Internet Explorer add support for Java

1996

JDK 1.0 Basic support for AWT

1997

JDK 1.1 JavaBeans, RMI, AWT, JDBC, servlets, JNDI, JFC, EJB

1998

Java 1.2 Reflection, Swing, Java Collections Framework, plug-in, IDL

Becomes known as Java 2, Port to Linux, Java Community Process

1999

Jini, PersonalJava, Java 2 Source Code, XML support, JavaServer Pages, Java Editions (J2ME, J2SE, J2EE)

2000

J2SE 1.3 HotSpot, RMI/CORBA, JavaSound, JNDI , JPDA

2001

Java Connector Architecture, patterns catalog, Java Web Start 1.0, J2EE 1.3

2002

J2SE 1.4 assert, regular expressions, exception chaining, NIO, logging, image I/O, integrated XML/XSLT, integrated Web Start, integrated JCE, JSSE, JAAS, J2EE 1.4 beta (Web Services)

2004

J2SE 1.5 (Java 5) Generics, auto-boxing, metadata (annotations), enums, “for-each”

2005

Java 10th Anniversary

2006

Java 1.6 (Java 6)

1.2. What is Java?

Java Technology consists of:

  • Java Language
  • Java Platform
  • Java Tools

Figure 1. Java technology

images/JDK.png


Java language is a general-purpose programming language. It can be used to develop software for mobile devices, browser-run applets, games, as well as desktop, enterprise (server-side), and scientific applications.

Java platform consists of Java virtual machine (JVM) responsible for hardware abstraction, and a set of libraries that gives Java a rich foundation.

Java tools include the Java compiler as well as various other helper applications that are used for day-to-day development (e.g. debugger).

1.3. Why Java?

  • Object oriented
  • Interpreted
  • Portable
  • Simple yet feature-full
  • Secure and robust
  • Scalable
  • High-performance multi-threaded
  • Dynamic
  • Distributed

Object Oriented
Everything in Java is coded using OO principles. This facilitates code modularization, reusability, testability, and performance.
Interpreted/Portable
Java source is complied into platform-independent bytecode, which is then interpreted (compiled into native-code) at runtime. Java’s slogan is "Write Once, Run Everywhere"
Simple
Java has a familiar syntax, automatic memory management, exception handling, single inheritance, standardized documentation, and a very rich set of libraries (no need to reinvent the wheel).
Secure/Robust
Due to its support for strong type checking, exception handling, and memory management, Java is immune to buffer- overruns, leaked memory, illegal data access. Additionally, Java comes with a Security Manager that provides a sand-box execution model.
Scalable
Thanks to its overall design, Java is scalable both in terms of performance/throughput, and as a development environment. A single user can play a Java game on a mobile phone, or millions of users can shop though a Java-based e-commerce enterprise application.
High-performance/Multi-threaded
With its HotSpot Just-in-Time compiler, Java can achieve (or exceed) performance of native applications. Java supports multi-threaded development out-of-the-box.
Dynamic
Java can load application components at run-time even if it knows nothing about them. Each class has a run-time representation.
Distributed
Java comes with support for networking, as well as for invoking methods on remote (distributed) objects through RMI.

1.4. Java After 15 years

  • 6.5+ million software developers
  • 1.1+ billion desktops with Java installed
  • 3+ billion mobile devices with support for Java
  • Embedded devices based on Java: set-top boxes, printers, web cams, games, car navigation systems, lottery terminals, medical devices, parking payment stations, etc.

Source: http://www.java.com/en/about/

Table of Contents

1. Overview of Java
1.1. History of Java
1.2. What is Java?
1.3. Why Java?
1.4. Java After 15 years
2. A Java Hello World Program
2.1. HelloWorld.java
2.2. Java Keywords
2.3. Java Identifiers
2.4. Compiling Java Programs
2.5. Running Java Programs
2.6. Comments in Java Code
2.7. The main() Method
3. Data Types
3.1. Declaring and Assigning Variables
3.2. Java Primitive Types
3.3. Conversion Between Types
3.4. Declaring Arrays
3.5. Creating and Initializing Array Objects
3.6. Modifying Array Size
3.7. Strings
4. Operators
4.1. Arithmetic Operators
4.2. Shortcut Arithmetic Operators
4.3. String Concatenation
4.4. Relational Operators
4.5. Logical Boolean Operators
4.6. Bitwise Operators
4.7. Assignment Operators
4.8. Other Operators
4.9. Operator Precedence
5. Statements and Flow Control
5.1. Expressions
5.2. Statements and Blocks
5.3. Local Variable Storage: The Stack
5.4. The return Statement
5.5. The if-else Statement
5.6. The switch Statement
5.7. The switch Statement (cont.)
5.8. The while Loop Statement
5.9. The for Loop Statement
5.10. Using for to Iterate over Arrays and Collections
5.11. The break Statement
5.12. The continue Statement
5.13. Nested Loops and Labels
6. Object Oriented Programming in Java
6.1. What is Object Oriented Programming (OOP)?
6.2. Why OOP?
6.3. Class vs. Object
6.4. Classes in Java
6.5. Objects in Java
6.6. Java Memory Model
6.7. Accessing Objects through References
6.8. Garbage Collection
6.9. Methods in Java
6.10. Methods in Java (cont.)
6.11. Method Declarations
6.12. Method Signatures
6.13. Invoking Methods
6.14. Static vs. Instance Data Fields
6.15. Static vs. Instance Methods
6.16. Method Overloading
6.17. Variable Argument Length Methods
6.18. Constructors
6.19. Constructors (cont.)
6.20. Constants
6.21. Encapsulation
6.22. Access Modifiers: Enforcing Encapsulation
6.23. Accessors (Getters) and Mutators (Setters)
6.24. Inheritance
6.25. Inheritance, Composition, and Aggregation
6.26. Inheritance in Java
6.27. Invoking Base Class Constructors
6.28. Overriding vs. Overloading
6.29. Polymorphism
6.30. More on Upcasting
6.31. Downcasting
6.32. Abstract Classes and Methods
6.33. Interfaces
6.34. Defining a Java Interface
6.35. Implementing a Java Interface
6.36. Polymorphism through Interfaces
6.37. Object: Java’s Ultimate Superclass
6.38. Overriding Object.toString()
6.39. Object Equality
6.40. Object Equivalence
6.41. Object Equivalence (cont.)
7. Packaging
7.1. Why is Packaging Needed?
7.2. Packages in Java
7.3. Sub-Packages in Java
7.4. Package Naming Conventions
7.5. Using Package Members: Qualified Names
7.6. Importing Package Members
7.7. Static Imports
7.8. Access Modifiers and Packages
7.9. The Class Path
7.10. Java Archive (JAR) Files
7.11. The jar Command-Line Tool Examples
8. JavaDoc
8.1. What is JavaDoc?
8.2. Reading Doc Comments (Java API)
8.3. Defining JavaDoc
8.4. Doc Comment Tags
8.5. Generating Doc Comment Output
9. Exceptions
9.1. What are Exceptions?
9.2. Why Use Exceptions?
9.3. Built-In Exceptions
9.4. Exception Types
9.5. Checked vs. Unchecked Exceptions
9.6. Exception Lifecycle
9.7. Handling Exceptions
9.8. Handling Exceptions (cont.)
9.9. Grouping Exceptions
9.10. Throwing Exception
9.11. Creating an Exception Class
9.12. Nesting Exceptions
10. The java.lang Package
10.1. Primitive Wrappers
10.2. String and StringBuilder
10.3. The Math Class
10.4. The System Class
11. Input/Output
11.1. Representing File Paths
11.2. Managing File Paths
11.3. Input/Output Class Hierarchy
11.4. Byte Streams
11.5. Character Streams
11.6. Exception Handling in Java I/O
11.7. Java File I/O Classes
11.8. Easy Text Output: PrintWriter/PrintStream
11.9. Reading from the Terminal
11.10. Filtered Streams
11.11. Object Serialization
12. java.net
12.1. java.net.InetAddress
12.2. URL/Connections
12.3. TCP Sockets
13. Java Collections and Generics
13.1. The Java Collections Framework
13.2. The Collection Interface
13.3. Iterating Over a Collection
13.4. The List Interface
13.5. Classes Implementing List
13.6. The Set and SortedSet Interfaces
13.7. Classes Implementing Set
13.8. The Queue Interface
13.9. The Map Interface
13.10. Retrieving Map Views
13.11. Classes Implementing Map
13.12. The Collections Class
13.13. Type Safety in Java Collections
13.14. Java Generics
13.15. Generics and Polymorphism
13.16. Type Wildcards
13.17. Qualified Type Wildcards
13.18. Generic Methods
14. Threading
14.1. Runnable And Thread
14.2. Thread Synchronization
14.3. More Thread Synchronization
14.4. Java 5 Concurrency Features
14.5. Thread Scheduling Pre-Java 5
14.6. Thread Scheduling In Java 5
14.7. Java 5’s ExecutorService
14.8. Getting Results From Threads Pre Java 5
14.9. Getting Results From Threads In Java 5
14.10. Thread Sync Pre-Java 5
14.11. Thread Sync In Java 5 With Locks
14.12. Benefits Of Java 5 Locks
14.13. Java 5 Conditions
14.14. Atomics In Java 5
14.15. Other Java 5 Concurrency Features
15. Additional Java Features
15.1. The Date Class
15.2. The Calendar Class
15.3. The TimeZone Class
15.4. Formatting and Parsing Dates
15.5. Formatting and Parsing Dates
15.6. Typesafe Enums
15.7. Typesafe Enums (cont.)
15.8. EnumSet and EnumMap
15.9. Annotations
15.10. Using Annotations
15.11. Standard Java Annotations
16. Java Native Interface (JNI)
16.1. JNI Overview
16.2. JNI Components
16.3. JNI Development (Java)
16.4. JNI Development (C)
16.5. JNI Development (Compile)
16.6. Type Conversion
16.7. Native Method Arguments
16.8. String Conversion
16.9. Array Conversion
16.10. Throwing Exceptions In The Native World
16.11. Access Properties And Methods From Native Code
17. java.sql
17.1. JDBC Overview
17.2. JDBC Drivers
17.3. Getting a JDBC Connection
17.4. Preparing a Statement
17.5. Processing ResultSet
17.6. Using ResultSetMetaData
17.7. Updates
18. XML Processing
18.1. Parsing XML with Java
18.2. Event-Driven Approach
18.3. Overview of SAX
18.4. Parsing XML with SAX
18.5. Object-Model Approach
18.6. Overview of DOM
18.7. Parsing XML with DOM
19. Design Patterns
19.1. What are Design Patterns?
19.2. Singleton
19.3. Factory Method
19.4. Abstract Factory
19.5. Adapter
19.6. Composite
19.7. Decorator
19.8. Chain of Responsibility
19.9. Observer / Publish-Subscribe
19.10. Strategy
19.11. Template
19.12. Data Access Object