AgerNic.com
WEB DEVELOPER SITE, HTML, CSS, PHP, SQL
HTML Tutorial

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:
String my_name = "Langford";
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);
  }
}

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:
int my_Number = 52;
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);
  }
}


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";





java variable type, variables, might not have been initialized, variables de entorno, globales, final, string, static, de clase, estatica
Java Variable - java

Online Editor
ONLINE EDITOR

news templates


COLOR PICKER

news templates
This tool makes it easy to create, adjust, and experiment with custom colors for the web.


HTML Templates
news 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
news templates
Find here examples of creative and unique website layouts.


Free CSS HTML Menu
news templates
Find here examples of creative and unique website CSS HTML menu.


0
Online Editor
ONLINE EDITOR

news templates


COLOR PICKER

news templates
This tool makes it easy to create, adjust, and experiment with custom colors for the web.


HTML Templates
news 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
news templates
Find here examples of creative and unique website layouts.


Free CSS HTML Menu
news templates
Find here examples of creative and unique website CSS HTML menu.


HTML Image tag, code...
How to code in HTML...
HTML text tag...
HTML text, how to display...
Container responsive styles...
HTML container tag...
HTML container...
Send forgot password by mail or message ...
PHP MySQL simple login system...
Check for duplicate username live or ema...
How to create simple search engine using...
Diseño de sitio web CSS Layout...
Diseño de caja flexible CSS3...
Botones en CSS...
ID y Clase, Diferencias entre Class e Id...
Esquina redondeada CSS...
Tamaño de caja css box-sizing: border-b...
Alineación CSS...
Altura y Anchura CSS...
Bordes CSS...