JavaSummary after basic course
One
1. Computer programs
Definition : a program is a collection of command sequences written in a computer language to achieve a specific goal or to solve a specific problem .
2. Directives
Definition : Instructions are instructions and commands that instruct the machine to work , and the program is a sequence of instructions .
For example:
:
Two Java -related technologies
Java is divided into three major versions
Java se <===============> J2 se Standard Edition
Java me <===============> J2 me miniature version
Java ee <===============> J2 ee Enterprise Edition
Among them , Javase (Java standard Edition) is The basis for all versions of Java , Javame (Java Mirco Edition) mainly for mobile phones and so on , Java java Enterprise Edition mainly develop Web programs . Java has now been replaced by andriod .
Java -related technologies include IOS (object-c), C (client)/S (server) programs, and more .
Three steps to develop a Java Program
1. There are three main steps to writing a Java Program :(1) writing the source program (2) compiling the source program (3) Run the program
:
2. Configure Environment variables
A. Right-click on my computer → properties → advanced system settings → environment variables → system variables, in system variables
To find the name of a variable with a path, click the "Edit" button and press the "Home" key to
Cursor is positioned to the first position
B. Open "My Computer" → Open drive C → find "Program Files folder" →java→jdk1.7.0_17→bin, copy Path
C. Paste the copied path to the cursor flashing position, followed by a semicolon (;)
D. Identify all the way through until all windows disappear.
F. Open "Start" → "Run" → Enter cmd→ input javac Enter, if a series of Chinese, prove the environment variable configuration success.
1. Writing code in Notepad
(1). In the root directory of the D drive, create a file with a suffix called Java named hello.
(2). Writing code
(3). Use the Javac command to compile a file with the suffix. Java as a file with the suffix. Class (bytecode file)
(4). A file with a. class suffix is run with the Java command, and the suffix name is not required when running.
The basic framework of the four Java programs
Five. Use of MyEclipse Tools
MyEclipse is more powerful than eclipse
Six. Escape character
\ n: Line break
\ t: a series of spaces
Seven. Annotation types
The role of annotations:
(1): Convenient for later maintenance of the project
(2): Easy to read by members of the team
(3): Comments will not be compiled by the Java compiler, Java compilation will be skipped over comments
Today there are two main types of annotations, namely single-line comments and multiline comments.
Single-line Comment://
Multiline Comment:/*
*
*
*/
▲: The annotated code block will not be executed while the program is running.
Eight. Things to keep in mind when writing Java programs
01.java code is strictly case sensitive.
02. Curly braces to appear in pairs
03. Write the left curly brace ({) At the end of a line of code
04. The code should be written into the inner frame.
05. All the code we write is in the English half-width state, otherwise error may occur
Each statement in 06.java ends with a semicolon
07. Class names cannot start with a number
Nine. Create a project in MyEclipse
01. Change Workspace: Click File→switch workspace→other→browser→ Select the D-Drive
A folder, click OK, the environment will automatically close. The first phenomenon: to quote a red fork, a second phenomenon: ask if we want to go to Software Center (software), tick the checkbox, click Cancel.
02. Create a Java project: Click File→new→java Project
03. Right-click on the src folder, New→class
04. Write the code, after writing, run the program through run (green triangle icon)
The results of the operation appear on the console console.
10. How to adjust the font size in MyEclipse
left mouse button click on the Windows >preferences, in the left side of the blank space to enter fonts, click Colors and Font, then click on the text font, continue to click Edit, you can freely choose the font you like.
Six. Java project Organizational Structure
(1). Package Explorer
Classes to manage multiple different functions
In the Package Explorer, a folder is formed on the hard disk every point you hit
(2). Navigator (Navigator)
Role: Similar to Windows Explorer, skills to see Java files, but also to see the compiled class file
Seven. MyEclipse Common operations
01. How to display line numbers
Right-click on the left-hand side of the code editing area, and in the popup menu, tick the
Show Line Numbers
02. Deleting items
Directly select the item you want to delete right-click and then find Delete, but note here, never tick, otherwise the real files on the hard drive will be removed. Then OK.
03. How do I import a project??
File→import→general, find the longest one, and then browser
04. How to rename a project
Select the name of the item you want to modify, press F2 on your keyboard, and then make sure you have modified it.
Eight. Errors that you often encounter when writing code with eclipse
(1) Syntax error, insert ";" To complete Statement
Syntax error: Insert semicolon to complete statement description
(2) When the definition string is missing double quotes, the error is described as follows:
Xxxcannot is resolved to a variable (cannot be parsed)
(3) The local variable sum may not be been initialized
Local variable ' sum ' may not be initialized
(4) Syntax error, insert ";" To complete
Syntax error, inserting ";" Complete
14. Java program compilation and execution process
01. The file with the suffix. Java is compiled by the Java compiler into a file with the suffix. class.
02. The file with the suffix. Class is compiled by the JVM (Java Virtual machine) for the second time and compiled into code that can be recognized by the CPU.
Java Basic Knowledge First