20165324 the first week of Java Program Design Study summary

Source: Internet
Author: User

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

    1. 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. )
    2. 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).
    3. 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
    • Java Learning Notes (8th Edition)
    • Git remote operation detailed

    • Java Learning Note (8th Edition) Learning Guide
    • Use Git to push code to open source China and the idea environment using git

20165324 the first week of Java Program Design Study summary

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.