Programming Language: Java
Topic: Variables and Data Types
Video: 2
_________________________________________________________________________________________
Variables and Data Types
Variable is a memory space in a system or a data container that save the data value during execution of the program. It can take any value like integer, string, character, float, etc. It is a very useful aspect in any programming language.
In Java while initializing a variable we have to define its data type. Where data type tells the system that which type of data is goin to be stored by the program.
Syntax:
data_type variable_name = value;
Code File: (Variables.java)
public class Variables { public static void main(String[] args) { Integer num = 15; Float fl = 13.1f; Double db = 12.34; Character ch = 'a'; String str = "V Code"; System.out.println(num.getClass().getSimpleName()); System.out.println(fl.getClass().getSimpleName()); System.out.println(db.getClass().getSimpleName()); System.out.println(ch.getClass().getSimpleName()); System.out.println(str.getClass().getSimpleName()); } }