Java language Overview

Source: Internet
Author: User
Tags create directory

Java language Overview

Basic KnowledgeInteractive mode

Graphical interface (graphical User Interface GUI) This method is simple and intuitive, easy to accept and easy to use.
command line mode (Command line Interface CLI): You need to have a console, enter specific instructions, and let the computer do some work. More trouble, need to record some commands.


Common DOS Commands

Dir (directory): Lists the files and folders in the current directory
MD (Make directory): Create directory
RD (remove directory): Delete directory
CD (Change directory): Enter the specified directory
CD: Back to top level directory
Cd\: Go back to the root directory
Exit: Exit DOS command line


What is computer language

Language: It is a way of communication between people. For example: Chinese and Chinese communicate in Mandarin. And the Chinese to communicate with the British, it is necessary to learn English.
Computer language (programming language): The way people communicate with computers. If the person wants to communicate with the computer, then must study the computer language. There are many kinds of computer languages, such as: c,c++,java,php, etc.

Java language Features

Object oriented
Two basic concepts: classes, objects
Three main features: encapsulation, inheritance, polymorphism
Robustness
It absorbs the advantages of C + + language, but removes the part that affects the robustness of the program. such as: pointers, memory applications and releases, etc.
Platform-based
Cross-platform: Applications written in the Java language can be run on different system platforms.
Rationale: Simply install a Java Virtual machine (JVM java VM) on the operating system that needs to run the Java application. The JVM is responsible for the operation of the Java program in the system.

Java program operating mechanismtwo core mechanisms of Java

Java Virtual machine (Java VM)
garbage collection mechanism (garbage Collection)


core mechanism-java virtual machines

The JVM is a virtual computer that has instruction sets and uses different storage areas. Responsible for executing instructions, managing data, memory, registers .
JVM used to run Java applications
For different platforms, there are different virtual machines.
The Java Virtual machine mechanism masks the difference between the underlying platform and implements "compile once, run everywhere".


core mechanism-garbage collection

Garbage collection: Reclaims memory space that is no longer in use.
In languages such as C + +, the programmer is responsible for reclaiming useless memory.
Java does not require programmers to reclaim useless memory : It provides a system-level thread to track the allocation of storage space. And when the JVM is idle, check and release the storage space that can be freed.
Garbage collection is performed automatically during Java programs, and programmers cannot control and intervene precisely .

Building the Java language environmentWhat is a jdk, JRE

Simply put, use the JDK's provided development tools to complete the development of Java programs, and use the JRE to run development-ready Java applications .
JDK (Java Development Kit Java SDK): JDK is available to Java developers with Java development tools and JRE. So with the JDK installed, you don't have to install the JRE separately.
JRE (Java Runtime Environment Java Run environment) : Includes Java Virtual machine (Jvm:java) and Java program required core class library, etc. If you want to run a well-developed Java program, you only need to install the JRE in your computer.


Download and install the JDK

Official website:
Www.oracle.com
Java.sun.com
Installing the JDK
Fool-mounted, next.
Recommendation: The installation path should not have Chinese or special symbols such as spaces.
When prompted to install the JRE, you can choose not to install.


Development Experience-helloworld

Steps:
Write the Java code in a file with a. java extension.
The Java file is compiled with the Javac command.
Run the class file from Java command

1 /*2 This is our first Java application.3 if the class is decorated with public, the class name must match the source file name4 Note: Multiline comments cannot be nested.5 */6 classhelloworld{7     //Main Method8      Public Static voidmain (String [] args) {9         //prints a string in the console.TenSystem.out.println ("helloworld!"); One     } A } -  - classtest{}

Summary of the first program

Main method: The execution portal of the Java application is the main () method. It has a fixed writing format: publicstatic void Main (string[] args) {...}
To interact with the JVM, simply add a System.out.println ("Hello World") to the Main method;
there can be at most one public class in a Java source file . The number of other classes is unlimited, and if the source file contains a public class, it must be named for that class name.
The Java language is strictly case sensitive .
The Java method consists of a single statement, with each statement ending with a semicolon .


frequently asked questions and how to solve

Show extensions for known file types
It is cumbersome to go into the bin directory with every tool that executes Java.
Depending on how the Windows system looks for executable programs, you can define the path where the Java tools are located in the PATH environment variable, and let the system help us find the program that runs the execution.
Configuration method:
My Computer--Properties--Advanced system settings--environment variables
Edit the PATH environment variable, and at the beginning of the variable value, add the directory where the Java tool is located (the bin directory of the JDK installation root), followed by ";" Separated from other values.
Open the DOS command line, typing javac in any directory. If the Javac parameter information appears, the configuration succeeds.

Notes

Note: The text used to interpret the description program. Improved readability of the code
Types of annotations in Java:
Single-line Comment
Multi-line comments
Document Comments (Java-specific)
A comment is a good programming habit that a programmer must have.
Put your thoughts through the comments first, and then use the code to reflect
Single-line Comment
Format: //Comment text
Multi-line comments
Format:/ * Comment text * /
For single-line and multiline comments, the annotated text is not interpreted by the JVM (Java Virtual machine).
Multiple lines of comment nesting is not allowed inside a multiline comment .

Java language Overview

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.