Sunday, September 22, 2013

What is a Data Type?

Data is, perhaps, the most essential part of programming. All Data in Java has a data type. Consequentially, all variables also have data types. Java, being a statically typed language, requires that variables must always be declared. The declaration of a variable is the way to notify the compiler and the JVM about
  1. the types of values that can be stored,
  2. the range of values that can be stored, and
  3. the capabilities provided by the variable.
This helps determine how much memory should be allocated for the variable and if a certain operation can be performed on a variable. Thus, the compiler can detect potential bugs in the code during the compile time itself. For example, what would the result of dividing a string by a number be? 

In Java, data types are classified as
  1. Primitive Data Types
  2. Reference Data Types

No comments:

Post a Comment