Java for Humans | Datatypes
Java datatypes have a simple purpose and that is to store different types of data in appropriate variables for efficiency in later use. Look at it in the case of a dog and an apple. Your dog is an animal and your apple is a fruit. You wouldn’t try to do the same things with your dog that you would with your apple, would you? Not sure? Try to make your apple bark. Another fortune of datatypes is predictability.
Why Datatypes are Important & Useful
Datatypes Give You the Power of Predictability
If you have a dog, you know for a fact that it can bark, so it would be okay to ask it to do just that. If you have an apple, you know for a fact it is okay to eat it because that’s what apples are for. But what if someone wrapped an apple in a dog suit and gave it to you without you knowing? You would try to make that dog bark, but nothing would happen. You would try to take it for a walk and it wouldn’t move. This is the same idea with datatypes in Java.
You can’t count with a String because strings represent characters that make concepts like words and stories like the one you are reading now. On the other hand, you can count with integers. However, if you try to make a word with an integer, nobody would understand it because integers only represent numbers.