JAVA Tutorial Manual

Read(64634) update time(2022-04-11)

This manual is a java online tutorial, which is a tutorial manual written for the high-level programming language java launched by Sun Microsystems in May 1995. Java can run on multiple platforms, such as Windows, Mac OS, and other UNIX versions of systems. This tutorial will let everyone better understand the JAVA programming language through simple examples.


Java is a widely used computer programming language with cross-platform, object-oriented, and generic programming features. It is widely used in enterprise-level web application development and mobile application development.

The style of the Java programming language is very close to the C language. It inherits the core of C language object-oriented technology, discards error-prone pointers and replaces them with references; removes the operator overloading and multiple inheritance features in C and replaces them with interfaces; adds a garbage collector function. Generic programming, type-safe enumerations, variable-length parameters, and autoloading/unboxing features were introduced in Java SE 1.5. Sun Microsystems' explanation of the Java language is: "The Java programming language is a simple, object-oriented, distributed, interpretable, robust, safe and system-independent, portable, high-performance, multi-threaded and dynamic language"

Java is different from general compiled languages ​​or interpreted languages. It first compiles the source code into bytecode, and then relies on virtual machines on various platforms to interpret and execute the bytecode, thus having the cross-platform feature of "write once, run anywhere". In the early JVM, this reduced the running efficiency of Java programs to a certain extent. However, after the release of J2SE1.4.2, the running speed of Java has been greatly improved.

Java basic syntax

Before writing a Java program, you should pay attention to the following points:

  • Case sensitivity: Java is case-sensitive, so It means that the identifier Hello and hello are different.

  • Class name: For all classes, the first letter of the class name should be capitalized. If the class name consists of several words, the first letter of each word should be capitalized, such as MyFirstJavaClass.

  • Method name: All method names should start with a lowercase letter. If the method name contains several words, the first letter of each subsequent word is capitalized, for example, myFirstJavaMethod.

  • Source file name: The source file name must be the same as the class name. When saving the file, you should use the class name as the filename (remember Java is case-sensitive) and the filename suffix .java. (If the file name and class name are different, a compilation error will occur).

  • Main method entry: All Java programs start execution from the public static void main(String[] args) method.

Let’s experience the first Java program!

The first Java program

Instance

public class HelloWorld {
    public static void main(String []args) {
       System.out.println("Hello World");
    }
}

Run instance»

Click "Run instance" " button to view online examples

Tips: Our Java tutorials will help you learn Java knowledge from beginner to advanced. If you have any questions, please go to the PHP Chinese website Java Community to ask your question, and enthusiastic netizens will answer it for you.

Java Usage

  • Desktop GUI Applications: Java provides GUI development through various methods such as Abstract Window Toolkit (AWT), Swing and JavaFX. While AWT includes many pre-built components like menus, buttons, lists, and numerous third-party components, Swing (a GUI widget toolkit) also provides certain advanced components like trees, tables, scroll panes, tabbed Panels and lists. JavaFX is a set of graphics and media packages that provides Swing interoperability, 3D graphics capabilities, and a self-contained deployment model to quickly script Java applets and applications.

  • Mobile Applications: Java Platform, Micro Edition (Java ME or J2ME) is a cross-platform framework for building applications that work on all Java-supported devices including feature phones and smartphones ) applications running on. Additionally, Android applications, one of the most popular mobile operating systems, are often scripted in Java using the Android Software Development Kit (SDK) or other environments.

  • Embedded Systems: From microchips to specialized computers, embedded systems are components of larger electromechanical systems that perform specialized tasks. Devices as diverse as SIM cards, Blu-ray Disc players, utility meters, and televisions use embedded Java technology. According to Oracle, 100% of Blu-ray Disc players and 125 million television devices are powered by Java technology.

  • Web Applications: Java provides support for web applications through Servlets, Struts or JSP. The simple programming and higher security provided by the programming language have made a large number of government applications available for health, social security, education and insurance based on Java. Java can also be used to develop e-commerce web applications using open source e-commerce platforms such as Broadleaf.

  • Web Servers and Application Servers: Today’s Java ecosystem consists of multiple Java web servers and application servers. While Apache Tomcat, Simple, Jo!, Rimfaxe Web Server (RWS), and Project Jigsaw occupy the web server space, WebLogic, WebSphere, and Jboss EAP hold significant positions in the commercial application server space.

  • Enterprise Applications: Java Enterprise Edition (Java EE) is a popular platform that provides APIs and runtimes for scripting and running enterprise software, including web applications and web services environment. Oracle claims that Java runs on 97% of enterprise computers. Higher performance guarantees and faster computing power in Java have led to high-frequency trading systems like Murex being scripted. It is also the hub for various banking applications that run Java from the front-end user side to the back-end server side.

  • Scientific Applications: Java is the choice of many software developers for writing applications involving scientific computing and mathematical operations. These programs are generally considered to be fast and secure, with greater portability and low maintenance. Applications like MATLAB use Java for interactive user interfaces and as part of the core system.

Content covered by this Java tutorial manual

This Java tutorial covers all basic and advanced knowledge of Java, including basic Java syntax, Java objects, classes, and Java data types , Java variable types, Java object-oriented and Java data structures, etc. All beginner and advanced knowledge of Java are introduced.

Tips: Each chapter of this tutorial contains many Java examples. You can directly click the "Run Example" button to view the results online. These examples will help you better understand and use Java.