Skip to main content

Featured

Java data types tutorial. How to create variables in java. Tutorial

Java Variables tutorial

Java is an awesome programming language and in this webpage we are going to learn that how a variables in Java can be developed.

java is case sensitive that means int and Int are different and you need to use int to not get error. 

First of all we will learn most commonly used variables in Java.

    String.
    int.
    float.
    char.
    Boolean.

We will learn all those variables linewise…


  1. String.     

In String, we can store a block of sentence and this is used show a sentence.

    String a = "this is sentence."
    System.out.print(a);

Output like this 

this is sentence.


2. int.

int is used to save a block of integer number. 

    int b = 67;
    System.out.print(b);

Output like this

67


3.float

Float is used to save a decimal number.

    float c = 97.8;
    System.out.print(c);

Output like this

97.8


4.char

Char is variable type to define and save a single letter from alphabet.

    char n = "p"
    System.out.print(n);

Output like this

p


And the last data type. 

5.boolean

Boolean is used to save data in true or false.

    boolean isJavaGood = true;
    System.out.print(isJavaGood);

Output like this

true

Comments

Popular Posts