Introduction to Java programming - Tutorial

Lars Vogel, Simon Scholz © 2008, 2019 vogella GmbH Version 2.9, 11.05.2017 TABLE OF CONTENTS 1. Introduction to Java 2. Installation of Java 3. Exercise: Write, compile and run a Java program 4. Base Java language structure 5. Java interfaces 6. Annotations in Java 7. Variables and methods 8. Modifiers 9. Import statements 10. More Java language constructs 11. Cheat Sheets 12. Integrated Development Environment 13. Exercises - Creating Java objects and methods 14. Solution - Creating Java objects and methods 15. Type Conversion 16. Java statements 17. Loops in Java 18. Arrays 19. Strings 20. Lambdas 21. Streams 22. Optional 23. System properties 24. Links and Literature 25. vogella training and consulting support Appendix A: Copyright, License and Source code Introduction to Java programming. This tutorial explains the installation and usage of the Java programming language. It also contains examples for standard programming tasks.

  1. Introduction to Java 1.1. A small history of Java Java is a programming language created by James Gosling from Sun Microsystems (Sun) in 1991. The target of Java is to write a program once and then run this program on multiple operating systems. The first publicly available version of Java (Java 1.0) was released in 1995. Sun Microsystems was acquired by the Oracle Corporation in 2010. Oracle has now the steermanship for Java. In 2006 Sun started to make Java available under the GNU General Public License (GPL). Oracle continues this project called OpenJDK.

Over time new enhanced versions of Java have been released. The current version of Java is Java 1.8 which is also known as Java 8.

Java is defined by a specification and consists of a programming language, a compiler, core libraries and a runtime (Java virtual machine) The Java runtime allows software developers to write program code in other languages than the Java programming language which still runs on the Java virtual machine. The Java platform is usually associated with the Java virtual machine and the Java core libraries.

The Java language was designed with the following properties:

Platform independent: Java programs use the Java virtual machine as abstraction and do not access the operating system directly. This makes Java programs highly portable. A Java program (which is standard-compliant and follows certain rules) can run unmodified on all supported platforms, e.g., Windows or Linux.

Object-orientated programming language: Except the primitive data types, all elements in Java are objects.

Strongly-typed programming language: Java is strongly-typed, e.g., the types of the used variables must be pre-defined and conversion to other objects is relatively strict, e.g., must be done in most cases by the programmer.

Interpreted and compiled language: Java source code is transferred into the bytecode format which does not depend on the target platform. These bytecode instructions will be interpreted by the Java Virtual machine (JVM). The JVM contains a so called Hotspot-Compiler which translates performance critical bytecode instructions into native code instructions.

Automatic memory management: Java manages the memory allocation and de-allocation for creating new objects. The program does not have direct access to the memory. The so-called garbage collector automatically deletes objects to which no active pointer exists.

The Java syntax is similar to C++. Java is case-sensitive, e.g., variables called myValue and myvalue are treated as different variables

This post is also available on DEV.