163k views
5 votes
Know when the double, int, String, and char data types are best used. Example: I would store a social security number in a string because the social can contain dashes and it is only used for displaying not for a mathematical equation.

1 Answer

6 votes
A double is best used for numbers that are real, as in they have a decimal. Int is best used for numbers that are whole, as in no decimal. Strings are best used, as in the example you gave, when you have to represent a piece of information that isn’t strictly numbers
User Greay
by
3.7k points