Java Variable
Java Tutorial » Java Variable
Variables are containers for storing data values.
In Java, we have different types of variables, example:
String - stores text, as "JavaTutorial" with double quotes
int - stores integers as 457 or -457 (whole numbers), without decimals,
float - stores floating point numbers, with decimals, as 27.98 or -27.98
char - stores single characters, as 'e' or 'E' with single quotes
boolean - stores values as: true or false
Ccreating a variable, must specify the type and assign it a value:
Syntax:
Example:
type variable = value;
Create a variable type string
Create a variable type string and assign it the value "Langford":
Example:
All java program:
Output: Langford
String my_name = "Langford";
System.out.println(my_name);
System.out.println(my_name);
All java program:
public class Main {
public static void main(String[] args) {
String my_name = "Langford";
System.out.println(my_name);
}
}
public static void main(String[] args) {
String my_name = "Langford";
System.out.println(my_name);
}
}
Output: Langford
Variable what store a number
Create a variable what store a number, example:
Example: Create a variable named my_Number of type int assign value 52:
Entire Java program:
int my_Number = 52;
System.out.println(my_Number);
System.out.println(my_Number);
Entire Java program:
public class Main {
public static void main(String[] args) {
int my_Number = 52;
System.out.println(my_Number);
}
}
public static void main(String[] args) {
int my_Number = 52;
System.out.println(my_Number);
}
}
Other Types of Variables
How to declare variables of other types, example:
Example: Create other variables type:
int my_Number = 27;
float my_Float_Number = 34.98f;
char my_Letter = 'E';
boolean my_Bool = false;
String my_Text = "Tutorial";
float my_Float_Number = 34.98f;
char my_Letter = 'E';
boolean my_Bool = false;
String my_Text = "Tutorial";
java variable type, variables, might not have been initialized, variables de entorno, globales, final, string, static, de clase, estatica
Java Variable - java
Online Editor
This tool makes it easy to create, adjust, and experiment with custom colors for the web.
HTML Templates

Magnews2 is a modern and creative free magazine and news website template that will help you kick off your online project in style.
CSS HTML Layout

Find here examples of creative and unique website layouts.
Free CSS HTML Menu

Find here examples of creative and unique website CSS HTML menu.