A variable in simple terms is a storage place which has some memory allocated to it. Basically, a variable used to store some form of data. Different types of variables require different amounts of memory, and have some specific set of operations which can be applied on them.
Syntax:
Datatype variable_name = variable_value;
Example:
To store the numeric value 25 in a variable named "a":
int a = 25;
Variables Rules:
This is a Java program that declares and initializes different types of variables and prints their values to the console.
The program declares and initializes the following variables:
The program then prints the values of these variables to the console using the System.out.println() method, along with a label for each variable.
//04 import java.lang.*; class variables { public static void main(String args[]) { String name="Tutor Joes"; int age=25; float percent=25.25f; char gender='M'; boolean married=false; System.out.println("Name : "+name); System.out.println("Age : "+age); System.out.println("Percent : "+percent); System.out.println("Gender : "+gender); System.out.println("Married : "+married); } }
Name : Tutor Joes Age : 25 Percent : 25.25 Gender : M Married : falseTo download raw file Click Here
Learn All in Tamil © Designed & Developed By Tutor Joes | Privacy Policy | Terms & Conditions