Der Primitive Datentyp (pl. Primitive Datentypen) – the primitive data type
This was also another thing that came up during my discussion with my friend, whom I was giving a short introduction to CS to. I mentioned primitive data types, but found that I couldn’t exactly give a definition either. I said that they were like something basic, in terms of classes. They are like something that “comes with” the language.
And then, I could only give examples of some:
- boolean
- char
- numbers
Yeah, I said numbers. I can’t believe that I forgot about all the different types of numbers. (But then again, I wasn’t really thinking about Java specifically. Because I’ve been learning Ruby recently, and, well, it’s not a strongly typed language, the variables there can store any data type without you having to specify.)
Embarrassingly, I also said string and array. Shows how much I know.
It also goes to show how some basic things you don’t need to know in order to be able to get other more advanced things done… kind of like how in language you don’t necessarily need to learn all about the grammar in order to be able to use it.
I remember vaguely that it has to do with how the data is stored, and turns out, that is also true to some extent. For Java, primitive data types store the value of the type, while non-primitives don’t. They only store a reference.
Before I end, let me give some correct information about the correct primitive types.
There are 8 primitive data types for Java, and they are:
- boolean
- char
- byte
- short
- int
- long
- float
- double
Leave a Reply