Java Basics Overview

Source: Internet
Author: User

for a novice class has not yet started beginners, now understand the collation of these points of knowledge is still a bit far-fetched, for many big guys to see, these understanding is somewhat superficial, but also need to understand my own knowledge of the new collation, so that in mutual study to find their own shortcomings, Hope that the Bo friends enthusiastically put forward their valuable comments, thank you! The following knowledge points are the summary of the knowledge I study today

JavaOverview:

java language, since it is a language, We can simply understand the language for us to communicate with the computer, through the dialogue with the computer, so as to accomplish the functions we need to achieve. In summary, java language is a programming language, through which to write a variety of programs and applications. java 1995 Span style= "font-size:14px;font-family: Song Body" > year, by sun The company was created, and was later oracle company acquisition, it's growing stronger.

Java language can write programs, then what kind of program can it develop?

l Desktop Applications: QQ , the , Thunder and so on

l   Internet: E-commerce, p2p et cetera

l Enterprise-level application development: OA , CRM wait

Doscommand:

     before we finish writing the source code, compile and run the time will use US windows command, which requires us to know dos Some of the common commands in the. First open the dos command window, open with: 1, press the keyboard at the same time Windows icon keys and r cmd Enter to open dos Command window: Here are some of the operations dos< Commands that are often used when span style= "font-family: Arial":

l CD. to return to the previous level of the directory or folder, such as the path now in c:\users\administrator>, execute the command to return to c:\users>

l cd\ returns directly to the root of the drive, as the path is now in c:\users\administrator>, and executes the command directly back to c:\>

l  CD filename                    Go to the folder below, as now the path is in c:\users> CD Administrator

l  CD disc : \ folder name           switch from the current drive to the folder under the specified drive letter, enter after the panel also displays the previous drive letter, which is also required to enter the specified drive letter return, you can enter the specified folder below, If the path is now in c:\users\administrator> F disk Java2017 below folder, CD F:\java2017 Enter will be displayed after \ c Users\administrator> f: You can enter the folder below after you enter it.

l Drive letter : switch from current drive letter to specified drive letter

l dir View all file information under current path \ Directory \ Folder

l cls clears The display information of the Dos window screen

l ipconfig view configuration information for Windows IP

JavaConstruction of the development environment:

Human development is inseparable from the environment, then the development of software to build its development environment, first we need to build a good environment for the development of Java language, that is, the need to download the installation of JDK (Java Development Kit ). The latest version of the JDK8 is now available .

JdkDownload and install:

Download: Open Browser input:http://www.oracle.com/cn/index.html, download the JDK installation package under this website .

Installation: Double-click the downloaded exe to run the file, follow the steps to install.

Jdkand theJre:

l JDK:Java SDK, which contains the JRE.

l JRE,Java Development Run environment, if you just need to run Java programs, install only the JRE.

JavaCross-platform features:

Java Program is a cross-platform, what is a cross-platform, as the name implies can be run on different platforms (operating systems), can be understood as a write run everywhere. It runs on a virtual machine (JVM), which means that only the corresponding version of the virtual machine needs to be installed on a different operating system.

Javaprocess written by the program:

1. source file: The programmer writes out the program's source file with the extension . java file

2. Compile: The source file is translated by the compiler into a byte-code file that can be read by the computer, which is the. Class file

3. run: run this bytecode . class file through the JVM.

both compile and run through Dos commands are compiled and run.

write the first small code:Hello World
public class helloworld{public static void Main (string[] args) {System.out.println ("Hello World"); }}

Public: Common, it is used to modify permissions, its permissions are the largest.

L class: Class, which defines a class whose functions are written in the class.

l Hello worls: Class name, note: The class name must match the file name.

l {}: Limit the scope of the class, all the code must be written in the curly braces inside, note: Playing this symbol is the keyboard to be in English state.

l public static void Main (string[] args) {} is the entry for the program, which starts from here, is fixed in its format, and cannot be changed

l System.out.println (""); This is the output statement, but also fixed, put the statement to be printed in parentheses inside the double quotation marks can be. Note: All symbols must be entered in the English state.

how to compile and run the above What about the Hello World code?

1.         compilation: In the dos command, first switch the path to the path where the file is located, find jdk", enter this path into dos javac helloworld.java Enter on it, this will appear in the source folder under a helloworld.class< Span style= "font-family: Song body" > This is the byte-code file that the computer can recognize.

2. run: After compiling, enter the JDK Toolkit under this path in the bin directory, enter the path into the Dos command, followed by the Java helloworld< c5> Enter to print out the statement inside the output statement.

To Configure environment variables:

you can see that the above code is run and compiled to find JDK in the path of Javac to compile, this will be very cumbersome, then you need to configure the environment variables, configuration and directly in the path of the source file to compile and run it is OK.

Step: Right-click My Computer- - Properties -- Advanced system Settings --The following environment variable in the Advanced tab under System Properties-- in the system variable there is a the path option double-click on the variable value to copy the bin directory under the JDK, move the cursor to the front, paste, and finally add English ; , note that the contents of the variable value must not be modified.

The role of annotations:

comments are mainly used to explain the source code you write, so that you or others can read and understand later.

comments can be divided into three types:

l Single-line comment://Comment content comment on a single line of code

l Multiline Comment:/* Comment content * * comment on multiple lines of code

l Documentation Comments:/** Comments * * A systematic introduction to the code, equivalent to a manual

The following code has a direct representation of single-line comments and multiline annotations:

/* Defines a print HelloWorld function implementation steps: 1, defines a Class 2, defines a Main method 3, implements the print to output the statement *///defines a class that is named HelloWorld class public class helloworld{//mai The N method, the fixed format, is the main entry that the program executes public static void main (string[] args) {//Output statements, which are used to print output System.out.println in the console (   "Hello World"); }}
Key Words:

The so-called keyword is The English word that is given special meaning in Java, like the public ,static,class, andvoid in the previous code are keywords , they can no longer be given other meanings,there are a lot of keywords in Java , there will be contacts in the future, so do not memorize. It is important to note that the keywords in Java are lowercase.

identifiers:

The so-called identifiers are defined by ourselves (except for keywords in Java) that can be called identifiers, which are written by uppercase and lowercase letters (a-z,a-z), Numbers (0-9), underscores (_ ), consisting of the dollar sign ($). Define identifiers to comply with their naming conventions.

Naming rules for identifiers:

l cannot start with a number

l cannot be a keyword in java

l strictly case-sensitive, to be able to see the name of the idea

There are two identifiers in the previous code:

definition of class name: HelloWorld, the first letter of all words capitalized, the remaining letters lowercase

definition of Method name:Main, first letter lowercase, and the first letter of the remaining words capitalized.


Java Basics 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.