20145326 Cai "Java programming" the first week of study summary

Source: Internet
Author: User
Tags netbeans java se

20145326 Cai "Java program design" the first week to summarize the learning content of learning materials

In a blink of an eye the new semester has finally begun! Why am I so looking forward to it? Because this semester can go to Lou Jia Peng Teacher's Java programming class, I am not what computer genius, before C linguistics is not particularly good. But I am particularly interested in HDL and Java (previously mentioned in my survey report), and during the winter vacation, I also preview a part of Java knowledge at home. The first week required to learn two chapters and experience, although I have seen the first two chapters of knowledge, but in order to further consolidate, I still use the week Children's Day days of the first chapter and the second chapter of the knowledge from beginning to end carefully looked at, while looking at the side of the experience, constantly find new problems and solve it, in order to improve and enhance! (Monday Children's Day Day, 8:30 A.M. start reading thinking to 12 o'clock noon, eat to sleep to two o'clock in the afternoon.) Then the fitness bath to eat and wash clothes to seven o'clock in the evening, then the blog from Seven O'Clock Night until the evening nearly 12 points. Although it took a long time, but I have to admit that the effect of this learning summary is really good! )

1 Introduction to the Java platform

To better use Java, you must first understand it in depth. The so-called 工欲善其事, its prerequisite. The first chapter of the book tells us about Java's past life, in its development process, its application field is more and more extensive, gradually evolved a different branch, Sun Company in June 1999 San Francisco Java One Conference announced the new Java architecture, The structure distinguishes different application versions based on different levels of application development, which are today's three platforms Java SE, Java EE, and Java ME. Java SE is the main object introduced in this book. Java SE is the foundation for learning other platform applications, and Java EE is built on the SE to develop distributed, multi-layered web-based applications, and Java me is the platform for development and deployment as a small digital device.

2 JVM/JRE/JDK

The underlying Java SE can be divided into four main parts: The JVM, the JRE, the JDK, and the Java language. In order to be able to run Java-authored programs, you must have a Java Virtual machine (JVM). The JVM is included in the Java Execution Environment (JRE), so you must install the JRE in order to run Java programs. If you want to develop Java programs, you must obtain JDK,JDK including the JRE and some development tools needed in the development process, such as Javac, Java and other tool programs. Understanding JVM JRE JDK is undoubtedly a necessary part of our learning process, the JVM is a virtual machine, its role is like a program translator, the class is translated into machine code, the JVM is the only operating system known to Java programs, Plainly, the system itself is unable to run the class file, with the Jvm,class file to run, and the JVM allows Java to cross the platform, each platform knows the sequence of 0, 1 is not the same, so you must use a different compiler for different platforms to compile the executable machine code, Java is a high-level language, and our goal is to have the program "compile once, execute everywhere". Java is not compiled directly into a sequence of 0 or 1 that is dependent on a platform, but rather as a bit code translated into a mediation format. Different platforms must have a dedicated JVM for that platform. This is the only way to achieve the "compile once, execute everywhere" purpose. The JVM is the only operating system known to Java, and a bit code document is the JVM's executable file. People are not able to survive in the right environment, Java is also the case, the JRE is the Java execution Environment, you can provide the required link library. The JDK provides a tool program, and the JDK itself includes the JRE. All in all, the three are a containment relationship, and the JDK has a JVM in the JRE,JRE. After installing the JDK, remember that the variables or options you set are set by yourself and the JDK does not do it. So far, there are many versions of the JDK, and when you want to run Java programs on different systems, just change the JDK version, which is why everyone says that Java can cross the platform.

3 simple Java program, Hello World

Start by setting "Show Extensions" under Windows, and then select a folder to compose the Java source document. Create a "text file" (i.e.. text file), save the Code, and rename it to Hello World.java. Determine the extension of the change text file. Note the extension must be. Java, and the main document name must be the same as the class name. Then open the DOS command line, switch directories to the newly-created folder directory, step into the operation, and finally implement Hello World. Class is the keyword used to define classes, followed by the class name. Public class Hello World means that Hello World is its public class, a Java document can define multiple classes, but only one exposes class, and the exposed class name and the main document name need to be consistent. The starting point after which the Java program executes is the main () method, which must be written in the form of public static void main (string[] args). Main () indicates that the JVM can be executed publicly, static means that the JVM can be called without generating a class instance, main () does not return a value, declared void, string[] args can get the user-specified command-line arguments when executing a program. The difference between println () and print () is that the output string is not wrapped. (The former will be wrapped after the output, the latter does not break the line)

4 Path\classpath\sourcepath

Path is an environment variable in the operating system, and when you enter an instruction without specifying the path information, the operating system will look for the command in the PATH environment variable according to the order of the paths set up in the path. We can execute echo%path% to see what path information is included in the current system PATH environment variable. There are two ways to set the path. One, SET path = "", enter "System Properties" click "Environment variables" to find the PATH directly modified. When set, there are multiple paths, separated by semicolons (;), which usually append the original path to the set value, so that the original path information can be used when looking for other instructions. Once the settings are complete, you can execute the Javac without specifying the path additional. It is recommended that you place the bin path of the JDK at the very front of the path variable, because the system searches for the path path, starting from the front.

Classpath: From the outset, it is emphasized that the JVM is the only operating system that the Java program recognizes, and for the JVM, the executable is the document with the. class extension. To execute an executable file (. Class) In the JVM, tell it which path to look for the document by specifying its executable (. Class) path information through Classpath. Classpath and path functions are similar, are the execution path of the instruction, different path is the search path for Windows, EXE and bat executable file, and classpath is the search path in the JVM, Use-classpath to specify the path information (also abbreviated as-CP) for the JVM for the executable file (. Class), such as JAVA-CP C:\workplace HelloWorld. The JVM's default classpath is to read the. class in the current folder. If you want to start looking for a class document from the current folder, you can use the "." Specified.

SourcePath: Specify a path for the JAVAC directive, and classpath to a degree similar to that used as Javac-sourcepath src Main.java ( Looking for Main.java in the SRC folder in the current path and compiling it into Main.class) at compile time, the-sourcepath specified folder is searched for the class source used, and then the classpath is searched for the compiled class code. After confirming the source code and the bit code search path, check to see if Classpath already has the main class compiled. If it exists and the original code of the main class has not changed since the last compilation, there is no need to recompile and, if it does not exist, recompile the main class.

5 Package This is a way of categorizing management classes to address file coverage issues: Java is placed in the SRC folder, and the compiled. Class is placed under the class folder. When using, that is, add the corresponding statement at the top of the Java document, such as the book Package Cc.openhome, the corresponding main class must be placed in the current Cc/openhome folder, the package defined by the name and class defined by the name, The exact name of the class that will be combined, and the original code document to be placed at the same folder level as the name hierarchy defined by the package. Because the console class is defined under the Cc.openhome.until package using the packages, the Console.java must be placed in the Cc\openhome\until folder in the SRC folder, and the folder must be created manually without tool assistance. When a class is specified in the source code, if it is a class in the same package, as long as the name defined by class is used, the class of the different package must use the exact match name. At compile time, if you have a location that uses the-D-point Locator, the corresponding package-level folder is automatically created, and the compiled code document is placed in its rightful place.

6 Import note that import just tells the compiler that it encounters a class name that you do not know, and you can try to use the name of the import, and import lets you make fewer words and let the compiler do more for you. However, there are limits to laziness, (examples in the book), and sometimes you have to make a clear word for yourself.

7.ide-target-source, in short, the IDE can do for us to do some source code document and bit code document and other resource management work, improve our efficiency. The main selection of the book is the NetBeans IDE for introduction. NetBeans can switch to the Files window to view the actual document management directly, and if we want to use the NetBeans execution program to enter the main () class, you can directly right-click on the Main.java file, choose "Run File" command in the popup shortcut menu, there will be an "output" The pane displays the results of the execution. This is much more convenient than using the DOS command line. For some compilation errors, it can also remind us, very humane. We can also switch the JDK version in NetBeans. Use-verbose to confirm the version number of the code document. At compile time, you can use-target to specify the compiled code, must conform to the specified platform allowed version number, using-source requires the compiler to check the syntax used, no more than the specified version. JDK8 the default-target and-source are 1.8,-target when specified, the value must be greater than or equal to-source.

Problems in teaching materials learning and the solving process

In the beginning of the learning process, the book will often use such as cd\ or CD. Dos commands like this, there will be many do not understand the beginning of reading, but by watching video materials and reading Lou Teacher's corresponding blog, the problem is solved. And there's the container. Containers are said to have a lot of different containers, some specific different things can only be placed in the corresponding container, and follow their own management, each different small container in a large container, is the JVM? I feel that a container is a Java application that is a system of application communication and coordination of related resources. Then, when learning about Classpath and SourcePath, there was a confusion about the difference between the two as a specified path, and ultimately through the observation of other compilations found in the book, Classpath is the find a bit code (. Class) file, SourcePath is to find the original code (. java) file, when using Classpath, the general is JAVA-CP ... When using SourcePath, it is generally javac-sourcepath ... The files specified by the two are different. The IDE is not very skilled at the moment, but I am really attracted to it, it greatly simplifies our Java operation process, more intuitive and easier.

Problems in code debugging and the resolution process

(I think this is the most interesting)

Use the console class to write HelloWorld (use other class link library exercises)

Code: public class main{public static void Main (string[] args) {Console.WriteLine ("Hello World");}}

I thought the computer itself came with the console class file, but it didn't actually, so I wrote a Console.java myself.

public class Console{public  static void writeLine(String text){ System.out.println(text);}  {

Because I put the console class and the main class in the Java folder in the C drive, I just need to go to the Java folder to execute Java main directly at compile time. However, if you do not put the console class and the main class together, you need to specify CLASSPATH for the JVM.

Other (sentiment, thinking, etc., optional)

I feel that when learning Java, book theory Knowledge and Practice operation is indispensable at the same time is not to be mixed up to talk about, "the paper came to the end of shallow, know this matter to preach" the truth is so, for the program class, mastered a certain theory, more practice is the king. The combination of theory and practice, constantly find the problem, and constantly overcome, can continue to progress! I remember in the first chapter of the study process, the book clearly written that the public class name must be the same as the main document name, when the reading thought firmly remember, feel very simple. But in the actual operation of the time will still make mistakes, visible experience of the importance of practical operation! When writing a Java document, it is also easy to confuse the case with the wrong size, and the question of the space. Finally found that the programming work is really a very meticulous work, read the book, does not mean that hands will, hope in the future, more hands-on practice, not lazy, not afraid of trouble, theory and practice, can form a meticulous and check the habit, little by little accumulation. Maybe I am a slow walker,but I never walk back!!

Learning progress Bar
Lines of code (new/cumulative) Blog volume (Add/accumulate) Learning time (new/cumulative) Important growth
Goal 5000 rows 30 Articles 400 hours
First week 200/200 2/2

20/20

Second week 300/500 2/4 18/38
Third week 500/1000 3/7 22/60
Week Four 300/1300 2/9 30/90
Resources
    • Java Learning Notes (8th Edition)
    • Java Learning Note (8th Edition) Learning Guide
    • ...

20145326 Cai "Java programming" the first week of 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.