In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-03-31 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)06/02 Report--
This article mainly introduces "what common anomalies are there in Java". In daily operation, I believe many people have doubts about what common anomalies there are in Java. The editor consulted all kinds of materials and sorted out simple and easy-to-use methods of operation. I hope it will be helpful to answer the doubts about "what common anomalies are there in Java?" Next, please follow the editor to study!
1. Java.lang.NullPointerException
We must often encounter this exception. The explanation of the exception is "the program has encountered a null pointer". To put it simply, it calls an uninitialized object or an object that does not exist. This error often occurs in the operation of creating a picture and calling an array, such as an uninitialized picture or a path error when the image is created. Null pointers appear in array operations, which in many cases are common mistakes made by some friends who are just beginning to learn programming, that is, they confuse the initialization of arrays with the initialization of array elements. The initialization of the array is to allocate the required space to the array, and after initialization, the elements in the array are not instantiated and are still empty, so each element needs to be initialized (if called).
2. Java.lang.ClassNotFoundException
This exception is a common problem for many programmers who were originally developed in JB and other development environments to compile packages under JB under WTk. The interpretation of the exception is that "the specified class does not exist". Here, we mainly consider whether the name and path of the class are correct. If you do the package under JB, it is usually added by default, so you should pay attention to add the path of Package after you go to WTK.
3. Java.lang.ArithmeticException
The explanation of this exception is "mathematical operation anomaly". For example, such an exception will occur when an operation such as dividing by zero occurs in the program. For this exception, we should carefully check the areas where mathematical operations are involved in our program. Is there something wrong with the formula?
4. Java.lang.ArrayIndexOutOfBoundsException
I believe many friends have often encountered this exception. The explanation of the exception is "array subscript is out of bounds". Now most programs have operations on arrays, so you must check carefully when you call an array to see if the subscript you call is out of the range of the array. Generally speaking, it is not easy to make such an error when calling (that is, directly using a constant as a subscript). However, implicit (that is, subscript with variables) calls often go wrong. In another case, the length of the array defined in the program is determined by some specific method, not declared in advance. At this time, it is best to check the length of the array first to avoid this exception.
5. Java.lang.IllegalArgumentException
The explanation of this exception is "method parameter error". Methods in many J2ME class libraries will cause such an error in some cases. For example, if the volume parameter in the volume adjustment method is written as a negative number, this exception will occur, such as the three values in the g.setColor (int red,int green,int blue) method. If there are more than 255, this exception will also occur, so once this exception is found. All we have to do is quickly check to see if there is an error in the parameter passing in the method call.
6. Java.lang.IllegalAccessException
This exception is interpreted as "no access", which occurs when the application wants to call a class, but the current method does not have access to the class. Pay attention to this exception if Package is used in the program.
At this point, the study of "what are the common anomalies in Java" is over. I hope to be able to solve your doubts. The collocation of theory and practice can better help you learn, go and try it! If you want to continue to learn more related knowledge, please continue to follow the website, the editor will continue to work hard to bring you more practical articles!
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.