JavaTpoint is a good example of a website about programming that sucks.
This is basically just a rant on how JavaTpoint sucks. Just to show how bad it really is. Note that many of my comments are sarcastic.
Block quotes and words in quotes are from JavaTpoint, unless stated otherwise. I followed most of the first topics (basics, OOP) and also Generics and Regular Expressions.
The Java section starts with this sentence:
Java Tutorial or Core Java Tutorial or Java Programming Tutorial is a widely used robust technology.
That makes no sense. “Java Tutorial” and the others are not technologies. The English is horrible. But exact wording is very important in tutorials and any kind of teaching material. My own English is far from perfect, but can’t they at least let some native speaker review their tutorials?
The tutorial doesn’t have a clear structure. Apparently we should first learn the history of Java. It then goes on with “Features of Java”. This actually mentions concepts like “Classloader” and “Bytecode Verifier”. I’m not sure a newbie would understand these just yet. The section about “High-performance” claims that Java is “slower” than C++. This is a common misconception but it makes no sense to compare languages. They have no speed. They are not cars. Would you say that English faster than French?
The next topic is “hello world”. Here the technical mistakes begin.
So it saves memory.
Who cares about memory? That certainly wasn’t the reason to make “main” static.
We will learn it later.
But where? This is HTML, so why not just link to it?
What’s that? Not everyone uses Windows. Since when do we need Windows for this tutorial? It never mentioned this. Why does this mention “var-args” here? Does the reader really need to know this before learning what those are?
It then goes on with a description of how to set the “PATH” variable (for some reason after we had to use them) and technical details about the JVM that a newbie surely wouldn’t understand.
It becomes more interesting on the page about
Variable and Datatype in Java: There are three types of variables: local, instance and static.
So parameters are not variables? They then mention primitive types and Unicode. Of course they ignore the fact that there are surrogate pairs and they claim that U+FFFF is the “highest value”. Then there’s a list of operators without their meanings.
It then goes on with “Java Programs”. The reader didn’t learn anything yet, but somehow we now get a list of “Java Programs”.
But then we learn about “Java OOPs Concepts”, which is surprising as we didn’t even learn about methods or how to do basic calculations or String processing. We also learn that a class is a “Collection of objects”, which is utter nonsense.
Like most bad tutorials it starts with “Inheritance”, giving the impression that this is somehow the basis of OOP. It doesn’t mention that composition is often the better choice.
They don’t even understand abstraction:
In java, we use abstract class and interface to achieve abstraction.
The text about encapsulation mentions “Java bean” without explaining what that is. The reader didn’t learn about those yet. It continues with a comparison of OOP vs procedural programming, even though the reader probably doesn’t know what the latter is.
A good book or tutorial has questions that the reader can use to check if she or he has understood everything. However the “Do You Know ?” section has questions, that weren’t covered in the tutorial, without answers.
Can we overload main method ?
How would I know? It didn’t cover method overloading yet.
The “Java Naming conventions” has a table, which is nice as it clearly shows the different rules. But how is “ActionListener” an adjective? Or how is “main” a verb? What are “constants” (the tutorial didn’t cover these!) and why does this claim that Java has constants?
It’s not clear how anyone could learn OOP like this. Do we now learn about objects? About memory (stack/heap)? About inheritance? It’s all mixed together.
So we finally get to learn what method overloading is. But why does the example for method overloading have two methods called sum that are void? Shouldn’t they return the sum as an integer?
It goes on with constructors:
Constructor in java is a special type of method that is used to initialize the object.
But that’s only true for byte code. In the Java language a constructor is not a method!
Constructor must have no explicit return type
So this is why so many students think a constructor has an (implicit) return type. But a constructor doesn’t return anything. So there is no type (not even implicit).
There are two types of constructors
…but I know more.
Default constructor provides the default values to the object like 0, null etc. depending on the type.
Just no! Fields get initialized before the constructor is invoked.
Q) Does constructor return any value? Ans:yes, that is current class instance (You cannot use return type yet it returns a value).
Tutorials about the static keyword are often plain wrong. This is no exception.
The static keyword in java is used for memory management mainly.
What?! Why would anyone think that?
They explain that “company name of employees” could be static. But why would you do that?! That would be horrible design. Only do that if you want to get fired.
It makes your program memory efficient (i.e it saves memory).
But a single class instance would be about the same memory size. Do they actually think that languages without static fields just waste a lot of memory?
This kind of bad design probably explains why object oriented designs are so bad if they are created by someone who tried to learn OOP from such a website.
jvm create object first then call main() method that will lead the problem of extra memory allocation.
Again with the memory allocation. How would that be a problem? They could have made it non-static and demand that there is a no-args constructor. It was a simple decision, but reduction of memory allocation certainly wasn’t the motivation.
So after static we learn about this. OK, that makes sense, since we now need to learn about non-static variables and methods.
1) The this keyword can be used to refer current class instance variable.
It refers to the variable? What variable? Doesn’t it actually behave like a variable that references the instance?
So the student barely understand how to create objects and how to define and invoke methods on those objects. The next topic is inheritance. A common problem is that students will think that inheritance is the solution to everything and that only with a lot of inheritance it’s OOP. But composition is often the better solution.
The idea behind inheritance in java is that you can create new classes that are built upon existing classes.
But inheritance is only one possible solution and in most cases composition is the better choice. It does not mention this here. However, most books don’t. And JavaTpoint actually has aggregation as the next topic. So that’s not too bad. Sadly it fails to explain the advantages of HAS-A relationships. The two points for “When use Aggregation?” are very good but not explained so that a beginner could understand them. And there are no examples to demonstrate the problems when you use inheritance.
They explain “Covariant Return Type” right after “Method Overloading”. It mentions that this is a bit more advanced so you could read it later. But where does it explain Contravariance and Invariance? This isn’t complete.
The super keyword is quite straightforward so I assume they didn’t make too many mistakes. But it is outdated. If they would try to keep the tutorials up to date then would have added the new use of super in Java 8, which is to reference an implementation in an interface.
I’ll skip the “Instance initializer block” because I’m more interested in the “final keyword”.
The final keyword in java is used to restrict the user.
Who is the user?! The user of what? Do they mean programmers?
It can be initialized in the constructor only.
I guess I shouldn’t have skipped the last topic. So they do not know that an initializer block can initialize final fields?
But this is about variables in general, not just fields. So final local variables can only be initialized in a constructor? That sounds odd.
If you make any variable as final, you cannot change the value of final variable(It will be constant).
Oh, so the object that is referenced can’t be changed, right? That’s what a beginner reads here. This is also why they do not understand the concept of final at all. The reader doesn’t even know what a “value” is and that a reference is a value too.
And what about paramters, local variables, variables that are used in lambdas? Can’t final be used there? Isn’t it relevant for those too? Wouldn’t a beginner want to learn about those?
If you make any method as final, you cannot override it.
So as I expected they forget about final static methods. And it doesn’t even explain why it is sometimes important to make a method final. Fragile Base Class Problem anyone?
If you make any class as final, you cannot extend it.
As final as what? OK, it’s just bad English. But that also means that all fields are final, right? I mean it’s what a beginner would assume. You wouldn’t assume that you still need to make all fields final.
I’ll skip “Polymorphism” and “Dynamic Binding” too. I doubt anyone really understands it from that tutorial. I don’t think it’s enough to explain and the examples do not really add much.
So “instanceof” is the next topic. I never knew that this is known as “type comparison operator”. Strange, since it doesn’t really compare types. This is a good example of a tutorial that explains some concept but fails to explain how to aviod it. Use of instanceof often just shows that there is some weakness in the design. This happens because no design is perfect. But you need to know that this is to be avoided and you need to know how.
Understanding Real use of instanceof in java
… just shows how to not use it. The students will think this is good design, but it’s bad design.
Next: “Abstract Classes”. I already mentioned that they confuse abstract with abstraction. For some reason abstract classes are twice in the tutorial (see above).
Before learning java abstract class, let’s understand the abstraction in java first.
Sadly, nobody will understand it from this tutorial.
Abstraction is a process of hiding the implementation details and showing only functionality to the user.
OK, but how is an abstract class relevant for that? You’d use interfaces to do that.
Their idea of abstraction is that an interface is 100% abstract(ion) and an abstract class is “0 to 100%”. But then you enforce that the abstract class is used and that is not abstraction.
They give an example where Shape is an abstract class, not an interface. But it doesn’t have any non-abstract methods or any fields. So what’s the point?
This teaches the bad practice of enforcing a base class when there should be an interface. Especially since Java 8 where you can have default implementations in interfaces.
So the next is “Interface in Java”. Somehow that is a “blueprint”. I’d say “contract”, but I guess they can explain it however they want. But I must mention that the official tutorial by oracle states this:
A class is a blueprint or prototype from which objects are created.
(Lesson: Object-Oriented Programming Concepts)
That makes more sense, because a class actually describes the object, while an interface is only a description of some behaviour that a class must provide.
It has static constants and abstract methods only.
Not since Java 8. So this topic is completely outdated.
By interface, we can support the functionality of multiple inheritance.
Of what? Here we can inherit type and behaviour, but that is not explained.
It can be used to achieve loose coupling.
Sounds interesting. What is that and how do we achieve it? JavaTpoint fails to explain this.
What is marker or tagged interface?
They could mention that we now have annotations to use instead of marker interfaces.
The next topic is packages, which I skip and continue with “Access Modifiers in java”:
There are 4 types of java access modifiers:  default
There is package-private, sometimes called default, but default is not an access modifier. This is important to know because default is actually a keyword.
The rest doesn’t seem so bad but there isn’t much about nested classes.
Encapsulation in Java
As far as I know the “Java Bean” was not covered so far. But maybe we learn it here? (No, we don’t).
By providing only setter or getter method, you can make the class read-only or write-only.
What is a write-only class? A beginner wouldn’t even understand read-only class. So if I only have getters it is read-only? There is nothing else to do? Strange, because the official tutorial by oracle lists few more things.
Now, let’s learn about “Object class in Java”.
The Object class is the parent class of all the classes in java bydefault.
So that’s just the default and I could use any other class? Is that what they mean by “bydefault”?
In other words, it is the topmost class of java.
Yes, those are other words.
What I already noticed is that the tutorial often claims that to compare and to check for equality is the same. I can compare 3 and 4 and see that 3 is less than 4. And I can check 1 and 0.9 for equality and see that they really are equal. A programmer must understand exactly what terms like compare and equality mean.
Object Cloning in Java: Less processing task.
That’s not wrong. But it doesn’t explain why and how to do a deep copy.
It’s time for “Java Array” now.
Normally, array is a collection of similar type of elements that have contiguous memory location.
But what if it’s somehow not normal?
Java doesn’t really have them. They are regular arrays – they simply refer to other arrays.
Passing Array to method in java
Why would you do that? Arrays aren’t meant for high level APIs.
And what about java.util.Arrays? Shouldn’t this also cover the methods of that utility class?
Next: “Wrapper class in Java”. They leave out some details about wrapper classes. For example:
Byte b = 42; int i = 42; System.out.println(b == i); // true System.out.println(b.equals(i)); // false
Call by what?
Next topic is “Call by Value and Call by Reference in Java”. However, the reader doesn’t really know what a value or a reference is. And a beginner doesn’t understand that Java will copy the value of a reference variable. They do not show any alternatives so a programmer who knows a language with call-by-reference (e.g. C#) would know what to do.
I skip the rest about OOP and continue with “Java String”:
It begins without explaining what “char” is and claims that the use of new String(char) is the same as a string literal. It even encourages students to use constructors, for no good reason. It does then explain how the string pool is important, but is this really the best way to start the tutorial?
It then goes on with:
string objects are immutable in java?
Because java uses the concept of string literal.Suppose there are 5 reference variables,all referes to one object “sachin”.If one reference variable changes the value of the object, it will be affected to all the reference variables. That is why string objects are immutable in java.
OK, that’s a new one. So could you please give an example of a language that does not use string literals, other than brainf*ck??? As far as I know languages such as PHP, Apple Swift, and Delphi also have string literals but their Strings are mutable. They do not have that problem, so this can’t be the reason. (Here’s why they are immutable)
But let’s continue with “Java String compare”: OK, so they cover equality and order of strings here. They could fix the text and replace “= =” by “==”.
The = = operator compares references not values.
But a reference is a value. And it compares that value. And why do they have this here? That’s not special for Strings. They would only need to remind the reader of this.
I skip the next topics but have a look at “charAt”. So they still do not explain what a “char” is. And they do not cover surrogate pairs here. So what’s the point? Anyone could just read the API for that.
So I skip the rest because it’s all just about the API.
But I do want to have a look at “Java Regex”. This is right after Strings and before basic concepts such as Exception Handling and Collections. It begins with:
The Java Regex or Regular Expression is an API to define pattern for searching or manipulating strings.
Where is this from? The official description of java.util.regex is:
Classes for matching character sequences against patterns specified by regular expressions.
(Java API: Package java.util.regex)
So readers of JavaTpoint will think that regexps are just fancy search patterns. But that is not the case.
The tutorial is quite a mess. It doesn’t really explain what this is about and just starts with some classes. Then there are examples, but no theory. I assume whoever wrote this doesn’t even know the theory behind regular expressions or finite state machines. So I guess this is just a very short introduction. But what’s the point of that? Nobody can use regular expressions from reading this.
Another topic I want to read is that about Generics. They do not even mention them in OOP, but they added them later.
Before generics, we can store any type of objects in collection i.e. non-generic.
So generics are about collections? This is why so many beginners think that generics are only for collections.
Now generics, forces the java programmer to store specific type of objects.
They probably mean elements, not objects.
There are mainly 3 advantages of generics. […] We can hold only a single type of objects in generics
What about polymorphism and wildcards?
There is no need to typecast the object.
Yes, but that is implicit.
It is checked at compile time so problem will not occur at runtime.
But you could simply extend the collection type and make it type safe. It was just more work, but you could do this in Java 1.4.
Here, we are using the ArrayList class, but you can use any collection class such as ArrayList, LinkedList,[…] etc.
Again, generics are not about collections. Students will not learn to use them if all their knowledge is based on this false assumption.
Most beginners will be rather confused now. A generic class isn’t a collection. So how can it be generic?
A class that can refer to any type is known as generic class
Not really. The parameter could have a bound. And you can’t use primitives (yet). So not any type.
The type parameters naming conventions are important to learn generics thoroughly.
I fail to see how this is so important. Especially if you leave out so many important information.
Like generic class, we can create generic method that can accept any type of argument.
But for that you’d just use Object as the type. It’s only generic if it has type parameters.
The example is bad because the use of a generic type parameter is completely irrelevant. They could simply use Object instead.
Wildcard in Java Generics
The ? (question mark) symbol represents wildcard element
How is this an element? Element of what? Of a collection? That makes no sense.
It means any type.
NO! NO! NO! It stands for the family of types with no bounds. Or call it unknown type. That’s not at all the same as any type!
If we write <? extends Number>, it means any child class of Number e.g. Integer, Float, double etc.
No, and double isn’t even a class.
Now we can call the method of Number class through any child class object.
No beginner would understand this!
Let’s understand it by the example given below:
Examples are good, but don’t just make them because your text is so bad. I doubt that anyone understands this from the given example. And many topics are still missing.
This explains why so many struggle with generics and regular expressions. They try to learn it from such crappy tutorials because to really understand the concepts you’d need to learn a lot of basics in discrete math. So they do not understand the theory and don’t even know it.
OK, so JavaTpoint sucks. I think I have more than enough proof to show how bad it is. Compare that to the official tutorials or any book. They are written by experts and reviewed by other peers. JavaTpoint was written by non-experts and rarely reviewed or updated. There are better sources for learning material such as websites by professionals (companies, such as Oracle, experts, such as Mkyong and Vogella, and schools, auch as MIT, NPTEL, Stanford) and books. Don’t waste your time on JavaTpoint.