“Apa itu var di java” Kode Jawaban

variabel java

//this are the most common ones
int x = 5; 
String y = "hello";
System.out.println(x + y);
Alexperto

Apa itu var di java

The var keyword was introduced in Java 10. 
Type inference is used in var keyword in which it detects automatically 
the datatype of a variable based on the surrounding context. 
The below examples explain where var is used and also where you can’t use it.
  

// Java program to explain that
// var can used to declare any datatype
  
class Demo1 {
  
    public static void main(String[] args)
    {
  
        // int
        var x = 100;
  
        // double
        var y = 1.90;
  
        // char
        var z = 'a';
  
        // string
        var p = "tanu";
  
        // boolean
        var q = false;
  
        // type inference is used in var keyword in which it
        // automatically detects the datatype of a variable
        System.out.println(x);
        System.out.println(y);
        System.out.println(z);
        System.out.println(p);
        System.out.println(q);
    }
}
SIKA T

Mengapa menggunakan var di java

improve the readability of code for other developers who read the code. 
In some situations
Good Gnu

Jawaban yang mirip dengan “Apa itu var di java”

Pertanyaan yang mirip dengan “Apa itu var di java”

Lebih banyak jawaban terkait untuk “Apa itu var di java” di Java

Jelajahi jawaban kode populer menurut bahasa

Jelajahi bahasa kode lainnya