Understand that in classes, materials and mainly on the internet people make simplifications. Probably your teacher made a simplification. Or he learned wrong, and he’s moving on, I don’t know :P
Every definition of terms needs a context. When you use a term in one context it can mean one thing, in another context it can mean something else, it cannot be the opposite, but there will be differences. The Java language could define what it regards as primitive types. It is her prerogative to define this in its context.
Even if it wasn’t this, still Java could say it is, if it wanted to.
What you learned in another discipline is true for that discipline, for that context. Probably in this context that learned are only considered primitive types in which most processors usually have dedicated instructions to manipulate them.
In the Java documentation there is a definition that the type string is part of the language and directly supported by the JVM and compiler, that’s it. But it is not defined as primitive. You can read more about it on "official" tutorial from Oracle. Often materials use wrong terms. And people reproduce this. And then others learn wrong.
If you know English you can read more about these guys on Wikipedia.
Some people don’t like this terminology. C# and other languages don’t even use it.
What can be considered primitive type is when the type is by value, but it depends on context, it is not so common.
The guy string is not a type by value itself. He is a pointer for the string, so it is a type by reference. But for all intents and purposes and it works as if it were a type by value, it has its own identity and it is not possible to change only a part of it, it is immutable.
Maybe that’s where the confusion comes from.
I don’t know if I should pass this but there’s an answer that helps understand the difference between types by value and by reference, but in C#. Don’t confuse it, Java is a little different. The basic idea is the same but Java, at least until version 8 does not allow you to create your own types by value. This one can also help (or confuse more, I don’t know).
I’ve talked about this in What is considered primitive in a programming language?.
String is rather primitive type in numerous languages, including some of relatively low level as Delphi/Object Pascal. The types above are the primitive types of the C language, although with different names. C++ still has Boolean and wchar as primitive types.
– epx