Since its advent in 1995, Java has been changing our lives and exceeding the expectations of people. The Sun Microsystems team that worked around the clock to develop this programming language targeted the digital television industry. As the concept of Java was too advanced at that time, it seemed perfect for the internet and other applications.
Over the time, object-oriented programming language Java has spread everywhere and created its own special place in the world of programming. The language is easy to learn but problems do exist in Java just like any other language. Here I’ll be covering the 10 most common mistakes made by every Java programmer.
To scan this enormous data set, Amjad Altadmri and Neil Brown from the University of Kent, UK put the mistakes in 18 possible categories. The programs were scanned for changes over the time by looking for the next compilation where the mistake was no longer present.
10 Most Common Mistakes Every Beginner Java Programmer Makes
Surprisingly, it was found that most common Java mistakes were actually a result of common misconceptions based on loose evidence. Here are the top 10 errors made by beginner Java programmers:- Unbalanced parentheses, curly braces, brackets, and quotation marks, or using these different symbols interchangeably, such as in: while (a == 0].
- Invoking methods with wrong arguments or argument types, such as in:list.get("abc").
- Control flow can reach end of non-void method without returning, such as in:
- Confusing the assignment operator (=) with the comparison operator (==), such as in: if (a = b).
- Ignoring or discarding the return value of a method with non-void return type, such as in: myObject.toString();.
- Use of == instead of .equals to compare strings.
- Trying to invoke a non-static method as if it was static, such as in:MyClass.toString();.
- Class claims to implement an interface, but does not implement all the required methods, such as in: class Y implements ActionListener { }.
- Invoking the types of parameters when invoking a method, such as in:myObject.foo(int x, String s);.
- Incorrect semicolon in if statements or for and while loops, such as in: if (a==b); return 6;.
Did you find this list of the 10 most common mistakes made by every Java programmer helpful? Share your views in the comments below.
0 comments:
Post a Comment