Thursday, April 21, 2022

JAVA - Data Types and Variables

1. Data Type - int

  •   The integer data type is used to store numeric/numbers in the variable. 
  •    But a decimal number can not be stored in the 'int' data type.

Example :

 package selenium;

 public class Java_practise {

 public static void main(String[] args) {

                int mark;

mark = 445;

System.out.println("suriya total mark in 10 th " + mark);

 }

 }


2. Data Type - char

  •   The character data type is used to store just one character in the variable. It is very rarely used in Selenium. 

Example :

 package selenium;

 public class Java_practise {

 public static void main(String[] args) {

char a;

                 a = 'S';

        //Print the value of the char variable

      System.out.println("Value of char is : " +  a);

}

}


3. Data Type - double

  •   To declare a variable used to hold such a decimal number, you can use the double keyword.

Example :

package selenium;

public class Java_practise {

public static void main(String[] args) {

double PI;

    //Initialize the double variable with value 'P'

        PI = 3.14159;

  //Print the value of the double variable

        System.out.print("PI: " + PI);

}

}



No comments:

Post a Comment