Java | Variables and Data Types | Tutorial 2

0

 

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());

    }

}
 

Post a Comment

0Comments
* Please Don't Spam Here. All the Comments are Reviewed by Admin.
Post a Comment (0)

#buttons=(Accept !) #days=(20)

Our website uses cookies to enhance your experience. Learn More
Accept !