Java learning from getting started to mastering (4)

Source: Internet
Author: User
Java learning path (4) Method

Java as a programming language, the best way to learn is to write code. After learning a class, you can write a simple example program to run it to see what the result is, and then call several more class methods to see the running result, in this way, the class is learned intuitively and the memory is very deep. The code should not be called. You should think about it. If I don't write it like this, try again. I remember which expert said that learning programming is a process of destruction. After running the examples in the book and learning the examples compiled by documentation, he constantly tries to implement them in different ways, constantly try to break the code structure and see what results it will have. In this way, you will have a thorough understanding of Java.

For example, we have compiled Hello world.

Public class helloworld {

Public static void main (string [] ARGs ){

System. Out. println ("Hello World ");

}

}

Many beginners do not quite understand why the main method must be defined as public static void main (string [] ARGs) in this way. Can it be written like this? This includes questions when I first learned Java. Do you want to know the answer? It is very simple. You should change the main name to run it to see what errors are reported and analyze them based on the error information. Remove the public of main and try again to see what errors are reported; static removal can still be run; do not know if the main method must pass a string [] array, change string [] to int [], or try it out; if you do not know whether to write the ARGs parameter name, you can also change the ARGs to another name to see how the running result works.

This is what I did when I first studied java. I modified the hello World Program seven or eight times and kept running and analyzed the running results, finally, I fully understand why the main method is defined in this way.

In addition, I didn't understand Staic, public, private, exception, try {} catch {} finally {} and so on at the beginning. They all succeeded in running the example above the reference books, then, I began to destroy it and constantly rewrite the program based on my questions to see if it could run, what it was like to run, and whether it could get the expected results. This is time-consuming, but an example program is destroyed several times in this way. I have completely learned the relevant knowledge. Sometimes you may even intentionally write some wrong code to run it and see if you can get the expected running error. In this way, we have a profound understanding of programming.

Among them, it is particularly worth mentioning that JDK has a very good debugging function,-verbose

Java? Cverbose

Javac? Cverbose and many other JDK tools have this option.

-Verbose can display the classes loaded by the JVM in sequence during command execution. Through these valuable debugging information, this helps us analyze what the JVM has done during execution.

In addition, many of the destructive routines you write during the learning process should be consciously stored in different categories, and the typical routines accumulated in your work should also be sorted regularly, you have a code library. If you encounter similar problems, just copy & paste, search & replace in the code library, which greatly improves the development speed. The ideal situation is to abstract some common routines to form a common class library and encapsulate them. The reusability is enhanced.

So I don't think it is really a special routine. The destroy routine you write is the best example. If you are not at ease with the code you write, I strongly recommend that you check the Java source code of the JDK base class library. There will be a src.zip under the JDK installation directory, and you can see the entire JDK base class library, that is, Rt. jar Java source code. You can refer to how sun writes Java programs and what the specifications look like. When I am learning Java class libraries, when I do not understand them clearly or want to understand the operation details more clearly, usually open the source code of the corresponding class. by looking at the source code, all problems will be swept away.

Java learning path (5) Resources

1. http://java.sun.com)

Sun's Java website should be visited frequently. Needless to say.

2. http://www-900.ibm.com/developerWorks/cn/

For the IBM developerworks website, go to the English site. This is not only an excellent Object-Oriented Analysis and Design website, but also an excellent website for Web Services, Java, and Linux. It is strongly recommended !!!

3. http://www.java-cn.com/(Chinese)

Java Chinese site. Currently, Java technology websites with the most comprehensive materials and members in China are very popular. Java e-book library and Java Video Library (the only one in China) main topics such as Java technical digest library, Java source code library, Java tool library, and recruitment and job search square. There are also some expert topics. Currently, there are more than 50 thousand VIP members and nearly 1000 VIP members. You can find what you need on cainiao or laruence's website !! It is strongly recommended !!!!!!

4. http://www.javaworld.com)

Discussions and news about many new Java technologies. I 'd like to know more about all aspects of Java, which is better here.

5. http://dev2dev.bea.com.cn/index.jsp

Bea's developer field, Bea, as the most important app server vendor, has many unique technologies that can be missed by partners who develop on weblogic.

6. http://www.huihoo.com/

The gray fox power website, a professional middleware website, is not a professional Java website, but has profound accomplishments in J2EE enterprise application technology.

7. http://www.theserverside.com/home)

Theserverside is a famous website dedicated to Java server applications.

8. http://www.javaresearch.org/

The Java research organization has many excellent articles and tutorials on Java, especially in JDO.

Http://www.cnjsp.org/

JSP technology websites have a considerable number of Java articles and resources.

Http://www.jdon.com/

Jdon forum is a personalized Chinese J2EE Professional Technology Forum. Among the many Java Chinese forums, jdon is a forum with high technical content and excellent post quality.

11. http://sourceforge.net/

Sourgeforge is the base camp of open source software, which also has a very rich set of Java open source famous software.

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.