N/APosted on - 03/22/2012
And also what are the difference between data type and operator?
Hi Leonard JAVA is the language that is derived from the basics of C which is developed by Dennis Ritchie in the year 1972 and JAVA is just can be said as an advanced to C due to its ease of use and advantages. Coming to JAVA we make use of the import statements to import files from the specific library we required by using import as the keyword.
Coming to the data type it refers to the storage value type whether the value is of type integer or float or any other data types are used to store values of an variable and syntax can be int,float,long,short etc….
Operator is simply defined for which we use to perform some operation on variable operators are required and the most used operator type is of arithmetic type of operators.
Java has sets of operators that allow you to manipulate variables and it is divided in the following groups: arithmetic operators, relational operators, bitwise operators, logical operators, assignment operators, and miscellaneous operators. Arithmetic operators are used in mathematical expressions the same way they are used in algebra. The following are the arithmetic operators:
- + (addition) – this operator adds values on either side of the operator. For example, where A holds 5 and B holds 10: A + B will give you 15.
- – (subtraction) – this operator subtracts right-hand operand from the left-hand operand. For example, where A holds 5 and B holds 10: A – B will give you -5.
- * (multiplication) – this operator multiplies values on either side of the operator. For example, where A holds 5 and B holds 10: A * B will give you 50.
- / (division) – this operator divides left-hand operand by the right-hand operand. For example, where A holds 5 and B holds 10: B / A will give you 2.
- % (modulus) – this operator divides left-hand operand by the right-hand operand and returns the remainder. For example, where A holds 5 and B holds 10: B % A will give you 0.
- ++ (increment) – this operator increases the value of the operand by 1. For example, where A holds 5 and B holds 10: A++ will give you 6.
-- (decrement) – this operator decreases the value of the operand by 1. For example, where A holds 5 and B holds 10: B– will give you 9.
For more information, go to Java Basic Operators. Data type, in Java, specifies the size and type of values that can be stored in an identifier. Different data types allow you to pick the right type according to the needs of the application. In Java, data types are classified into two types: primitive and non-primitive. The primitive data type includes floating point, integer, character, and Boolean.
The non-primitive data type includes arrays, classes, and interfaces. For more information, go to Java for Beginners.