search
HomeJavajavaTutorialIntroducing the basic principles of Java
Introducing the basic principles of JavaJul 16, 2017 pm 04:56 PM
javaprinciplepersist in

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 and the big data hadoop framework) Written in java, Spark is written in Scala, Scala is written in java), (relative to other languages) simple and easy to learn, safe and reliable, completely object-oriented, cross-platform (operating system, completely ignore the operating system, after writing Any operating system can be used).

java is compiled and run through the java virtual machine.

The Java virtual machine is the general term for various commands for compiling and running Java programs and their operating environment. After compilation, the Java source program generates a file with the suffix ".class", which is encoded in bytecode. This bytecode is actually a pseudocode that contains various instructions that are basically platform-independent instructions. The Java virtual machine interprets these bytecodes on the basis of bytecode files (and files with a .class suffix generated by compilation), converts these bytecodes into machine codes of the local computer, and hands them to the local computer for execution.

In this way, bytecode is actually a kind of platform-independent pseudo-code, which is turned into machine code on various platforms through Java commands. These pseudocodes are ultimately run on the local computer platform, but the Java program seems to run on the basis of these Java commands, so the collection of these Java commands seems to be a virtual computer implemented using software technology. This is where the name Java Virtual Machine comes from.

The process of Java virtual machine executing bytecode consists of a loop. It continuously family programs, performs legality and security testing, and interprets execution until the program is executed (including abnormal exit). The Java virtual machine first loads the bytecode from the file with the suffix ".class" into the memory; then it detects the legality and safety of the code in the memory, for example, detecting whether the array used by the Java program is out of bounds and the memory to be accessed Whether the address is legal, etc.; then interpret and execute the code that passes the test, and convert the bytecode into machine code for the corresponding computer platform according to different computer platforms, and then hand it over to the corresponding computer for execution. If the loaded code cannot pass the legality and security detection, the Java virtual machine executes the corresponding Exception handling program. The Java virtual machine continues to execute this process until the program execution ends. Although the Java language contains compilation commands, the Java virtual machine's interpretation and execution mechanism of bytecode determines that the Java language is an interpreted and executed language.

Cross-platform principle

Java Virtual Machine---Java Virtual Machine---JVM, different Java virtual machines have been developed for different operating systems. A Java program is not directly It runs on the computer but on the Java virtual machine. The Java virtual machine translates the Java program 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", in the original variable value Add ";%JAVA_HOME%\bin;%JAVA_HOME%\jre\bin" at the end
(3) New -> Variable name "CLASSPATH", variable value ".;%JAVA_HOME%\lib;%JAVA_HOME% \lib\dt.jar;%JAVA_HOME%\lib\tools.jar”

Keyword

means that it is given a special meaning in Java word

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

##Keywords used to define ifelseswitchdoKeywords used to define access modifiersprivateKeywords used to define classes, functions, and variable modifiersabstractKeywords used to define the relationship between classesextends is used for definition Keywords for creating instances and determining instancesnew##instanceofcatchfinallyimportstrictfp
##Keywords used to define

data types

class

interface

byte

short

int

long

float

double

char

boolean

void

enum

Keywords used to define data type values

true

false

null

process control

##case

## default

while

for

break

continue

return

protected

public

final

static

synchronized

implements

##this

super

Keywords used for

Exception handling

try

##throw

throws

Keywords used for packages

package

Other modifier keywords

native

transient

volatile

assert

##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 and 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

The above is the detailed content of Introducing the basic principles of Java. For more information, please follow other related articles on the PHP Chinese website!

Statement
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
带你搞懂Java结构化数据处理开源库SPL带你搞懂Java结构化数据处理开源库SPLMay 24, 2022 pm 01:34 PM

本篇文章给大家带来了关于java的相关知识,其中主要介绍了关于结构化数据处理开源库SPL的相关问题,下面就一起来看一下java下理想的结构化数据处理类库,希望对大家有帮助。

Java集合框架之PriorityQueue优先级队列Java集合框架之PriorityQueue优先级队列Jun 09, 2022 am 11:47 AM

本篇文章给大家带来了关于java的相关知识,其中主要介绍了关于PriorityQueue优先级队列的相关知识,Java集合框架中提供了PriorityQueue和PriorityBlockingQueue两种类型的优先级队列,PriorityQueue是线程不安全的,PriorityBlockingQueue是线程安全的,下面一起来看一下,希望对大家有帮助。

完全掌握Java锁(图文解析)完全掌握Java锁(图文解析)Jun 14, 2022 am 11:47 AM

本篇文章给大家带来了关于java的相关知识,其中主要介绍了关于java锁的相关问题,包括了独占锁、悲观锁、乐观锁、共享锁等等内容,下面一起来看一下,希望对大家有帮助。

一起聊聊Java多线程之线程安全问题一起聊聊Java多线程之线程安全问题Apr 21, 2022 pm 06:17 PM

本篇文章给大家带来了关于java的相关知识,其中主要介绍了关于多线程的相关问题,包括了线程安装、线程加锁与线程不安全的原因、线程安全的标准类等等内容,希望对大家有帮助。

详细解析Java的this和super关键字详细解析Java的this和super关键字Apr 30, 2022 am 09:00 AM

本篇文章给大家带来了关于Java的相关知识,其中主要介绍了关于关键字中this和super的相关问题,以及他们的一些区别,下面一起来看一下,希望对大家有帮助。

Java基础归纳之枚举Java基础归纳之枚举May 26, 2022 am 11:50 AM

本篇文章给大家带来了关于java的相关知识,其中主要介绍了关于枚举的相关问题,包括了枚举的基本操作、集合类对枚举的支持等等内容,下面一起来看一下,希望对大家有帮助。

java中封装是什么java中封装是什么May 16, 2019 pm 06:08 PM

封装是一种信息隐藏技术,是指一种将抽象性函式接口的实现细节部分包装、隐藏起来的方法;封装可以被认为是一个保护屏障,防止指定类的代码和数据被外部类定义的代码随机访问。封装可以通过关键字private,protected和public实现。

归纳整理JAVA装饰器模式(实例详解)归纳整理JAVA装饰器模式(实例详解)May 05, 2022 pm 06:48 PM

本篇文章给大家带来了关于java的相关知识,其中主要介绍了关于设计模式的相关问题,主要将装饰器模式的相关内容,指在不改变现有对象结构的情况下,动态地给该对象增加一些职责的模式,希望对大家有帮助。

See all articles

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

AI Hentai Generator

AI Hentai Generator

Generate AI Hentai for free.

Hot Article

R.E.P.O. Energy Crystals Explained and What They Do (Yellow Crystal)
2 weeks agoBy尊渡假赌尊渡假赌尊渡假赌
Repo: How To Revive Teammates
1 months agoBy尊渡假赌尊渡假赌尊渡假赌
Hello Kitty Island Adventure: How To Get Giant Seeds
4 weeks agoBy尊渡假赌尊渡假赌尊渡假赌

Hot Tools

mPDF

mPDF

mPDF is a PHP library that can generate PDF files from UTF-8 encoded HTML. The original author, Ian Back, wrote mPDF to output PDF files "on the fly" from his website and handle different languages. It is slower than original scripts like HTML2FPDF and produces larger files when using Unicode fonts, but supports CSS styles etc. and has a lot of enhancements. Supports almost all languages, including RTL (Arabic and Hebrew) and CJK (Chinese, Japanese and Korean). Supports nested block-level elements (such as P, DIV),

SublimeText3 Linux new version

SublimeText3 Linux new version

SublimeText3 Linux latest version

Notepad++7.3.1

Notepad++7.3.1

Easy-to-use and free code editor

PhpStorm Mac version

PhpStorm Mac version

The latest (2018.2.1) professional PHP integrated development tool

Dreamweaver CS6

Dreamweaver CS6

Visual web development tools