Java notes-java related concepts and how to implement cross-platform

Source: Internet
Author: User

I. Java-related concepts

Core features of 1.Java language
Cross-platform
Object oriented

Historical version of 2.Java
jdk1.0,jdk1.1,jdk1.2 .... jdk5.0,jdk6.0,jdk7.0,jdk8.0

Note: JDK5.0 is an iconic version that introduces a number of new features.

Classification of 3.Java
Java starts from 1.2 and is divided into three different branches

Javase (Java standard Edition), Java Standards Edition, dedicated to developing desktop-class applications
Java EE (Java Enterprise Edititon), Business Edition, specializing in the development of large enterprise-class applications
Javame (Java micro Edition), Java Mini Edition, dedicated to the development of mobile device applications

4. Other
Jdkjava Development Kit,java Development Kit
Jrejava Runtime Environment,java Operating environment
Jvmjava Virtual Machine,java VM
Apiapplication Provider Interface, application interface
Spiservice Provider Interface, service Provider Interface

--

Two. How is Java implemented across platforms?

C Program Run

Software
Operating system
Hardware

Java program run

Java programs
JRE (JVM provides running environment)
JVM (JVM is implemented in C language, it is a software)
Operating system
Hardware

Note: A true cross-platform is a virtual machine JVM!!!

Xxx.javajava source files, write Java source code, people can read
Xxx.classjava bytecode file, written in binary, machine can read

Compile run
Source files--------> bytecode files----------> results

Summarize:
Java source files that can be understood by the JDK are compiled with a bytecode file that can be read by the machine.
This bytecode file is loaded into the JVM of different platforms and can be run across platforms!

--
cmd command line common commands

1. Start the command line
Start-to-run input Cmd/win + R + cmd

2. Toggle Drive Letter
Drive letter:

3. Go to the folder
CD folder name
CD path

Note: The path can be either an absolute path or a relative path.

Absolute path, with drive letter, executes only one location on the computer
Relative path, without drive letter, which may point to multiple locations

4. Exit the folder
Cd.. Step back to the previous level
Cd.. /.. /.. Exit Multilayer

5. Auto-Completing
tab

6. Clear the screen
Cls

7. Recall command
Top and Bottom Buttons

--

Three. How do I write a Java program?

1. Download the appropriate operating system JDK from Oracle website first
2. Install JDK, configure environment variables
A. Right-click My Computer, properties, advanced tags, environment variables
B. New
Variable name: java_home
Variable value: The path to the JDK, for example: C:\Program files\java\jdk1.7.0_25
C. Edit path, and add it before the value of path's original variable:
%java_home%\bin;
3. Verify that the environment variable configuration is successful,
Run->cmd, enter Java and javac validation

4. Write a Java file with a. java file suffix, and this file is called a Java class.

Create the Workspace workspace folder, build the SRC folder and the bin folder inside,
SRC is used to store well-written Java source files, and bin is used to store compiled bytecode files.

How do I write a Java class?

Package name;

public class class Name {
public static void Main (string[] args) {
Code
}
}

Attention:
A. The class name must be highly consistent with the source file name
B. Curly braces appear in pairs

5. Compiling and Running
Locate the file directory in SRC

(1). Compiling and running in SRC
Compile:
Javac-d. /bin Helloworld.java

Compile the Helloworld.java into a byte-code file, Helloworld.class, and put the file into
The bin folder in the top level directory.

Run the Helloworld.class bytecode file:
JAVA-CP. /bin Com.tz.day01.HelloWorld

(2). Compile and run in the workspace root directory
Compile:
Javac-d bin Src/helloworld.java

Run:
Java-cp bin Com.tz.day01.HelloWorld;

--

Output statement

System.out.println (...);

ln indicates that the output is wrapped in parentheses after wrapping!

Note that the output statement supports mathematical operations and the connection of strings

--

Packages (Package)

1. Function:
A. Namespaces used to extend a class
B. Used to manage class files

2. Naming conventions for packages:
All in lowercase letters, in the middle with. Separate, the enterprise often uses the company domain name inversion to name

Com.qq.image
Com.qq.test
Com.qq.entity
Com.qq.dao
Com.qq.dao.impl
Com.qq.config
..

Note: The package name. Class is called the fully qualified name of the class
COM.TZ.DAY01.HELLOWOLRD, the runtime must be a fully qualified name!

--

Comments:

Single-line comment//

Multi-line Comment/**/

Document Comment/***/

Role: Used to illustrate the code, the current learning phase we can use it as a note in the code, easy to review
In the enterprise, the annotation is very important!

--

The main method, which is the main entrance of the program, must have this method if the program wants to run.

public static void Main (string[] args) {

}

--

Get user Keyboard input
0. Import
Import Java.util.Scanner;

1. Create a Scanner object
Scanner sc = new Scanner (system.in);

2.
SYSTEM.OUT.PRINTLN ("hint ...");

3.
int i = Sc.nextint ();//integer

String s = sc.nextline ();//A Word

Java notes-java related concepts and how to implement cross-platform

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.