How to write good code for beginners in Java

Students who are new to Java often encounter such a situation. They have followed the introductory tutorial and read it, but when they need to write the code themselves, they are unable to start. When writing code, they often encounter places they do not understand. It may take a lot of time. If you skip over it, there may be more and more problems in the future. How to find a balance? Whether these problems can be handled well will also affect the ability to further study Java programming in the future.
Most of us didn't learn programming since we were young, but only started to get into programming gradually after having a certain foundation in mathematics, computer and English, which means that everyone has different foundations and different ways of thinking, so how do you as a beginner? There is no unified and correct way to write Java code. Mr. Chen from Shangxuetang will give you advice based on his personal experience.

1. Lay the grammar foundation of Java from the beginning
In fact, every Java tutorial pays more attention to the grammar foundation of Java, but this does not mean that you can learn Java by reading the grammar knowledge in the textbook. In the process of learning Java, the author pays more attention to gradually mastering the grammar in the process of doing exercises. From easy to difficult, step by step. First of all, we must pay attention to distinguishing the case of letters in the code. Generally speaking, the first letter of the class name should be capitalized, and the first letter of the method name should be lowercase; in the process of learning grammar, we should also consider it from an object-oriented perspective, understand the class and object relationship.
Classes in Java should be kept in mind so that they can be used flexibly in the future. A good Java programmer doesn't just use code that someone else has already implemented. If you want to know the classes in Java well, it is very important to look at the source code in the JDK with a focus. It is a good helper for us to learn Java syntax.

2. Type more code on the basis of being familiar with the IDE
Many students used Notepad to type code when they were first learning Java, but with the increase of the amount of code, it is not advisable to use Notepad. Familiar with the IDE's development integrated environment can help us type out the standard code. Commonly used IDEs are eclipse, JBuilder, Idea, etc. These IDEs will report errors in time when we type the wrong code, so that we know our own grammar and other errors at the first time, and it is very important for beginners to gradually master the Java language. s help.

3. Practice the content of the study in time
Because the content of Java covers a wide range, it also leaves us a broad training space. In terms of database, you can consider using the small database MySQL to practice your hands, and use Java for data injection and data extraction, which involves many classes related to time and date. Of course, when it comes to the database part, you need to be more familiar with SQL; in the process of practice It is also necessary to use various interfaces. There is JDBC related to the database, which is a commonly used API. It is often used when doing management information systems. At the same time, there is also Servlet, which is also an interface. Beginners can start to understand from here. And the project that contacts JavaWeb, understands the code of Java continuously in the practice.

When you encounter a problem that you don't know, of course you can't ignore it, pass it by, and you can't spend too much time on a certain problem, which requires certain learning skills. For example: if you encounter difficulties in the process of learning recursion, you can find out the content related to recursion, especially some examples, to see which part you are not clear about; knowledge in Java has a strong correlation, if a If you don’t understand a place, you can use other peripheral knowledge to understand it backwards, so that it will not delay the learning progress, and at the same time, you can understand the places you don’t understand.

In short, when learning Java development, it is normal to encounter things that you don’t understand, but as long as you have the right direction, clear thinking, perseverance, and more hands-on practice, you will definitely be better after learning.

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=325558883&siteId=291194637