Java First Day notes
A Common DOS commands in window
Where to operate DOS commands:
Win7---> Start----"All Programs---" accessories----"Command prompt
Win7--> Start---"Run----" Input cmd
1.1 Drive Symbol Switching:
Disk Fu Yi + colon format: drive letter:
Example: Want to drive from C to D
C:/user/xxxx D:
1.2 Working with folders
Dir: Displays all files and folders in the current folder.
CD path: Enter to the specified path.
Cd.. : Go back to the top level directory
CD \: Back to the current directory with the directory
MD folder name Create a folder
Rd Folder name Delete Folder action
1.3 Operation of the file
echo data (content) > file name Create a file and specify the data.
Type file name to view the contents of the specified file
Del file name deletes the specified file
* Wildcard Characters
Tab fill Content
CLS Clear Screen
Up and DOWN ARROW keys to retrieve the last written content
Exit close the console.
The History of Language:
Machine language: 0101010101010
Assembly language: Using a large number of English words to express instructions
Advanced languages: C,oc, c++,php, Java
History of the Java language:
1993, Java original set-top box 1994 Internet has just emerged, 1995java officially released all a version.
Java is divided into 3 versions:
1.JavaSE
2.javaEE---> j2e
3.javaME
One of the most important features of Java: cross-platform (operating system).
What is cross-platform:
Compile once and run everywhere.
Is the Java Virtual Machine cross-platform?
No cross-platform, just a broker: Let this java instruction be recognized by the operating system.
JVM (Java Virtual machine, just for Java systems)
Java features two: open source
Complete the first Java program:
1. A Java virtual machine is required.
Building the Java Environment:
Jre:java the operating environment. Jre = Java Virtual machine + Core class library (auxiliary Java running files);
Jdk:java development tool Set JDK = JRE + Java Development tools
Install JDK: Be aware that there is no Chinese in the directory.
Description of the JDK directory:
Development tools for Bin:java
Db:jdk7 comes with a miniature database derby
Include: The file that holds the calling system interface
Jre:java Operating Environment
Lib: Core Class Library
The source code of the Src.zip:java.
Development tools for Java
Javac.exe:java compiler to compile the source file into a. class file
Java.exe: The Java file is running
Problem: There is no way to work with files and tools separately.
We want to: find the file directly and compile it through Javac.
Path environment variable
How to configure path:
My Computer---Right--"Properties---" Advanced system settings---"Environment variables-" System Variables-"Path---> Edit (double-click)
Locate the file directory where the Java development tools are located, copy the directory, paste it to the back of the path, and then give it a semicolon at the end of the Win7 paste (English)
C:\Program Files (x86) \intel\icls client\; C:\Program Files\intel\icls client\;%systemroot%\system32;%systemroot%;%systemroot%\system32\wbem;%systemroot%\ System32\windowspowershell\v1.0\;c:\program Files (x86) \quicktime\qtsystem\; C:\Program Files (x86) \tencent\qq\bin; C:\Program Files\java\jdk1.7.0_51\bin
Green: The system does not need to change the default, red is the path we need to add, there is a blue semicolon.
If I am in the d:/Javac, the system will find in the current folder whether there is a javac executable file, the path in the environment is not the default to be configured to look for if it is found to run, not the report is not an internal instruction.
First Java program: Hello Hi
1. Create a new Notepad and change the suffix name to. java
2. Right-click Edit
3. Create a class in Java
Class Demo1 {
Main function
public static void Main (string[] args) {
System.out.print ("Hello hi"); No Line break printing
System.out.println ("Hello hi");//newline Print
}
}
4. Save Ctrl +s
5. Enter the directory where the file is located (CD command to enter the file) javac the source file. java
6. Generate A. class file
7. Run the. classs file Java class name
Two. Identifiers
In Java programs, some names can be defined by themselves, so these custom names we call him a custom identifier.
system default identifiers: Keywords and reserved words
Identifier naming note points:
1. Identifiers can only be composed of letters (A-ZA-Z), Numbers (0-9), underscores _, dollar sign ($)
2. Cannot start with a number
3. Strictly case-sensitive
4. Cannot be named by keywords and reserved words.
5. Identifier names are not limited in length
6. Name the identifier to make sense.
Naming conventions for identifiers:
1. The first letter of the class name and interface list Word, the other lowercase
2. Name of the variable and the name of the method the first letter is lowercase, the first letter of the other word is capitalized, and the other is lowercase.
3. Package name All words lowercase
4. Constant all words capitalized words and words are separated by underscores such as: pi_2
The following identifiers conform to the standard:
12AVBC non-conforming with a number beginning
_12ADAV_ compliant
@hhgg $ does not meet
$DFGDF _* does not meet
[email protected] does not conform to an element that does not belong to an identifier.
Three Key words:
Identifiers with special meanings in Java, called keyword keywords, are typically used to describe the structure of a program and the types of variables
Four Comments in Java
/* Comment
OC: Two types of
1. Single-line Comment://
2. Multiline Comment:/* contents of comment */
3. Documentation Comments:/** Comments */
Java: three kinds
1. Single-line Comment://
2. Multiline Comment:/* contents of comment */
3. Documentation Comments:/** Comments */
Note the details that need attention:
A multiline comment cannot be nested, and a single-line comment can be used in a nested set.
The role of annotations:
1. EXPLANATION procedure
2. Debug the program.
Javadoc Generating the document:
*/
Java Note 1