20165324 "Java program design" the first week to summarize the learning contents of teaching Materials Chapter I: Getting Started with Java
Key one, write Java programs
- The first step is to write the source file (Note: Java is strictly case-sensitive in the first step; the Java source file has the same extension as the *.java generic Java source filename and the class name. Save the type as all files. )
- The second step compiles, (note: The second step uses the Javac command to compile the source file, such as:
javac Hello.java after compiling a bytecode file, the bytecode file has the same file name and class name, the bytecode file extension is *.class).
- The third step runs, (note: The third step uses Java commands to run, Java followed by the class name or the file name of the bytecode file, such as the
java Hello final output).
Key two, the teaching Material Example analysis: (Explanation from the NetEase cloud classroom)
class Hello{ public static void main(String[]args){ System.out.println("Hello World!"); }}
- Java programs must be defined in a class, and the process of writing a Java program is to constantly define the class's process
- Use class to define a class
- Hello is a programmer's name
- The contents of the class need to be enclosed in a pair of large brackets.
- To run the program, you must write the main method, and the main method is written in a fixed
- Public indicates a common
- Static represents a statically
- Void means that the main method has no return value
- Main is a method name
- The parentheses behind main are the parameters of the method
- String[]args is an array that defines a string type
- The method body of the main method also needs to be enclosed in a pair of braces.
- System.out.println ("helloworld!"); is a statement, and the Java statement ends with the English semi-colon semicolon
- The function of the previous statement is to print a line of information on the screen, that is, the contents of the double quotation mark are printed on the screen
- System is a class defined by sun company that represents a class of systems
- System.out represents the system's standard output device, which is the default display
- Note that the symbols in Java are all English half-width
- println () is a method that prints a line of information on the screen
Key points about the source file:
- The defined classes must be stored in the Java source file
- In general, the Java source file name is the same as the class name
- If the class name is not the same as the source file name Javac compile, followed by the source file name, but the resulting bytecode file, the bytecode filename is the same as the class name
- In general, only one class is defined in a Java source file
- Multiple classes can be defined in the Java source file, and each class will generate a corresponding bytecode file after compilation
- Different classes in the same source file can have the main method, whether a class needs to define the main method, depending on whether the class needs to be run to determine
- A class can be decorated with public as a common class, and a package is used to manage classes, and if a class in a package wants to use a class in package B, the class in package B must be defined as public, and the class name of the common class must be the same as the file name
Note: Bytecode files are platform-independent, and this bytecode file can only be executed by the JVM. In different platforms (Windows platform, Linux platform, Mac platform) to install different versions of the JVM, no matter what version of JMV can execute bytecode files, through this mechanism can realize the cross-platform, platform neutrality of Java.
Problems in teaching materials learning and the solving process
- Question one: In use, you should choose Bash to run the command, or the GIT bash app
- Workaround: When using the Bash command, you need to install UBUNTN through the relevant command line, and then command-line instructions to enter the UBUNTN, using the root account login (the above through Baidu's own understanding of the gains, can not be clearly correct or not); and Git bash is a simulation environment, Use git commands just like Linux and Unix. It's as if you're using Git bash.
- Question two: What are the relevant commands for the collation of the catalog files in the first lesson?
- Workaround: Bin is the program directory; src is the source code directory; Include is the system folder; The LIP directory is the repository file.
- Question three: When uploading code via git push, is the authentication error?
fatal: Authentication failed for ‘https://gitee.com/hcj_20165324/java-besti-is-hcj.git/‘
- WORKAROUND: The code Cloud user name is:
- Problem four: Git bash files are garbled in Chinese.
- Workaround:
- Problem five: Git bash interface appears garbled in Chinese
- Workaround: Do not know.
Code Hosting
Script Run
Code Cloud Project Existing file
Resources
20165324 the first week of Java Program Design Study summary