Table of Contents
Java
Technical Structure of Java
JDK/JRE/JVM
Compile
Environment variables
Keywords
Identifier
Definition rules: 5 points
Camel case naming method
Comments
Format
Home Java javaTutorial An in-depth analysis of how Java works

An in-depth analysis of how Java works

Jul 17, 2017 pm 01:24 PM
java principle Base

Java

is a high-level programming language launched by SUN in 1995. It is an Internet-oriented language and the preferred language for WEB applications (the bottom layer of Android, the big data hadoop framework is written in java, and Spark is written in Scala Written in Scala (written in Java), (relative to other languages) it is easy to learn, safe and reliable, completely object-oriented, and cross-platform (operating system, completely ignore the operating system, and can be used on any operating system after writing).

The concept of virtual machine is introduced in Java, which adds an abstract layer of virtual machine between the machine and the compiler. This virtual machine provides a common interface to compilers on any platform. The compiler only needs to be oriented to the virtual machine, generate code that the virtual machine can understand, and then the interpreter will convert the virtual machine code into machine code for a specific system for execution. In Java, this kind of code for the virtual machine to understand is called bytecode (ByteCode) (the content of the class file). It is not oriented to any specific processor, only to the virtual machine. The interpreter for each platform is different, but the virtual machine implemented is the same. The Java source program is compiled by the compiler and becomes bytecode. The bytecode is interpreted and executed by the virtual machine. The virtual machine sends each bytecode to be executed to the interpreter, and the interpreter translates it into a machine on a specific machine. code and then run it on a specific machine.

Principle of cross-platform

In other words, in Beijing, people generally speak Beijing dialect. In Shanghai, people generally speak Shanghai dialect, Guangdong, and Guangdong. If so...
An official document has been issued and needs to be implemented nationwide. What should we do? ——First translate into Mandarin. Various places are translating the Mandarin version into local dialects.

Here, Beijing and Shanghai are different types of machines, windows, linux...
Compilation (javac) is the process of translating official documents into Mandarin, and the compiled .class file is the Mandarin version of the official document. Version.
During execution, the translator in various places is jvm, which is responsible for converting .class into a dialect that can be understood by the local area for execution.

Java Virtual Machine---Java Virtual Machine---JVM, different Java virtual machines have been developed for different operating systems. A Java program does not run directly on the computer but runs On the Java virtual machine, the Java virtual machine translates Java programs into commands that the current system can recognize. The Java language is cross-platform, but the Java virtual machine is not cross-platform.

Technical Structure of Java

J2SE---Standard Edition

J2EE---Enterprise Edition

J2ME---Mobile Edition (Some people used it in the early days , almost no longer used now)

JDK/JRE/JVM

JVM---The premise that Java can be cross-platform

JRE---Java Runtime Environment---Java Runtime environment---JVM+core class library

JDK---Java Development Kit---Java Development Kit---Development Tools+JRE

java.sun.com

www.oracle.com

In 1994, it was called Oak---Oak

and later changed to Java---Java

JDK1.0(-JDK1.1 -1.2 (Applet/swing---GUI was later eliminated) -1.3-1.4-1.5 (JDK5.0, ten features)---JDK6---JDK7.0---JDK8 (can also be called 1.8/ten Features) By 1.8, there are more than 3,000 classes and interface methods

(75 after Jdk1.7.0_75 means 75 updates, no matter which version is installed, try not to use the first 50 minor versions)

C:\\Program Files(X86)

Note: Do not have spaces or Chinese characters in the installation path!

Compile

Compile Java The process of translating the code into a language that the computer can understand

Note:

1. The file name of the class file corresponds to the class name

2.After each class is compiled, it will Generate a class file

3. The class name of the public class must be consistent with the file name of the Java file

4. The entry point for the Java program to run is the main function. Without the main function, the Java program can be compiled

Environment variables

refers to the amount of some operating parameters specified for the operating system

(1)New->Variable name "JAVA_HOME", variable value "C:\Java\jdk1.8.0_05" (that is, the installation path of JDK)
(2) Edit -> Variable name "Path", add ";" at the end of the original variable value %JAVA_HOME%\bin;%JAVA_HOME%\jre\bin”
(3) New->Variable name “CLASSPATH”, variable value “.;%JAVA_HOME%\lib;%JAVA_HOME%\lib\dt.jar ;%JAVA_HOME%\lib\tools.jar”

Keywords

refers to words that have been given special meanings in Java

There are 53 keywords in total, 51 of them are in use, and 2 are not currently used---const, goto---reserved words

##voidenum#Keywords used to define data type valuestruefalsenull##Keywords used to define process controlifdoKeywords used to define access modifiersprivate##implementsthiscatchKeywords used for packagespackageimportnative

Note: All keywords are in lowercase!

Identifier

The name customized in the program

Definition rules: 5 points

1 can be composed of letters, numbers,_,$- --It is not recommended to use the $ symbol

2You cannot use pure numbers, and numbers cannot be used as the beginning

3You cannot use keywords

4Java is a strictly case-sensitive language

5 In order to improve the readability of the program, try to be familiar with the name

Supports Chinese naming, but is not recommended

class A{}

class a{} can be written like this, but Windows does not allow it. Windows is not case-sensitive

Camel case naming method

Class name/interface name

If it consists of multiple words, The first letter of each word is capitalized HelloWorld

Variable name/method name

If it consists of multiple words, the first letter of the first word is lowercase, and the first letter of the remaining words is capitalized playGame

Package name

If it consists of multiple words, all letters must be lowercase, separated by .

Constant name

If it consists of multiple words, All letters are in capital letters, separated by _

Comments

Text used to explain or explain the program in the program

Format

//annotation text Single-line comments

/*&*/ Multi-line comments

/**&*/ Documentation comments---are often used to annotate classes, methods or constants

javadoc -d .\\document Demo.java---This command can only be used to extract the content of document comments in public classes

Keywords used to define data types

class

interface

byte

short

int

long

float

double

char

##boolean

else

switch

case

default

while

for

break

##continue

return

protected

##public

is used to define classes, functions, and variable modifiers Keywords

abstract
final

static

synchronized

##Keywords used to define relationships between classes

extends

Keywords used to define the creation and judgment of instances

new

super

instanceof

Keywords used for exception handling

try

finally

##throw

throws

##Other modifier keywords

strictfp
transient

volatile

assert

The above is the detailed content of An in-depth analysis of how Java works. For more information, please follow other related articles on the PHP Chinese website!

Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

Video Face Swap

Video Face Swap

Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Tools

Notepad++7.3.1

Notepad++7.3.1

Easy-to-use and free code editor

SublimeText3 Chinese version

SublimeText3 Chinese version

Chinese version, very easy to use

Zend Studio 13.0.1

Zend Studio 13.0.1

Powerful PHP integrated development environment

Dreamweaver CS6

Dreamweaver CS6

Visual web development tools

SublimeText3 Mac version

SublimeText3 Mac version

God-level code editing software (SublimeText3)

Perfect Number in Java Perfect Number in Java Aug 30, 2024 pm 04:28 PM

Guide to Perfect Number in Java. Here we discuss the Definition, How to check Perfect number in Java?, examples with code implementation.

Weka in Java Weka in Java Aug 30, 2024 pm 04:28 PM

Guide to Weka in Java. Here we discuss the Introduction, how to use weka java, the type of platform, and advantages with examples.

Smith Number in Java Smith Number in Java Aug 30, 2024 pm 04:28 PM

Guide to Smith Number in Java. Here we discuss the Definition, How to check smith number in Java? example with code implementation.

Java Spring Interview Questions Java Spring Interview Questions Aug 30, 2024 pm 04:29 PM

In this article, we have kept the most asked Java Spring Interview Questions with their detailed answers. So that you can crack the interview.

Break or return from Java 8 stream forEach? Break or return from Java 8 stream forEach? Feb 07, 2025 pm 12:09 PM

Java 8 introduces the Stream API, providing a powerful and expressive way to process data collections. However, a common question when using Stream is: How to break or return from a forEach operation? Traditional loops allow for early interruption or return, but Stream's forEach method does not directly support this method. This article will explain the reasons and explore alternative methods for implementing premature termination in Stream processing systems. Further reading: Java Stream API improvements Understand Stream forEach The forEach method is a terminal operation that performs one operation on each element in the Stream. Its design intention is

TimeStamp to Date in Java TimeStamp to Date in Java Aug 30, 2024 pm 04:28 PM

Guide to TimeStamp to Date in Java. Here we also discuss the introduction and how to convert timestamp to date in java along with examples.

Java Program to Find the Volume of Capsule Java Program to Find the Volume of Capsule Feb 07, 2025 am 11:37 AM

Capsules are three-dimensional geometric figures, composed of a cylinder and a hemisphere at both ends. The volume of the capsule can be calculated by adding the volume of the cylinder and the volume of the hemisphere at both ends. This tutorial will discuss how to calculate the volume of a given capsule in Java using different methods. Capsule volume formula The formula for capsule volume is as follows: Capsule volume = Cylindrical volume Volume Two hemisphere volume in, r: The radius of the hemisphere. h: The height of the cylinder (excluding the hemisphere). Example 1 enter Radius = 5 units Height = 10 units Output Volume = 1570.8 cubic units explain Calculate volume using formula: Volume = π × r2 × h (4

Create the Future: Java Programming for Absolute Beginners Create the Future: Java Programming for Absolute Beginners Oct 13, 2024 pm 01:32 PM

Java is a popular programming language that can be learned by both beginners and experienced developers. This tutorial starts with basic concepts and progresses through advanced topics. After installing the Java Development Kit, you can practice programming by creating a simple "Hello, World!" program. After you understand the code, use the command prompt to compile and run the program, and "Hello, World!" will be output on the console. Learning Java starts your programming journey, and as your mastery deepens, you can create more complex applications.

See all articles