Use of variable JAVA

Capture

Use of variable


Variable is a memory location that has been given a name and can be assigned a value during the execution of the program. Variable naming rules together with other programming languages ​​such as C, C ++, Pascal, etc.

Java coding examples using an integer data type variables:
01public class ContohInteger{
02public static void main(String args[]){ int v1;
03int v2; int v;
04v1=70; v2=30;
05v=v1+v2;
06System.out.println(v1+" + "+v2+" = "+v); v=v1-v2;
07System.out.println(v1+" - "+v2+" = "+v); v=v1*v2;
08System.out.println(v1+" * "+v2+" = "+v); v=v1/v2;
09System.out.println(v1+" / "+v2+" = "+v); v=v1%v2;
10System.out.println(v1+" % "+v2+" = "+v);
11}
12}

GIF
coding results, will result in an integer (integer) of the accretion process, subtraction, division, multiplication.

Examples of java coding using variable data type float or double:
01public class Contoh3{
02public static void main(String args[]){ double v1;
03double v2; double v;
04v1=23.34; v2=12.223;
05v=v1+v2;
06System.out.println(v1+" + "+v2+" = "+v); v=v1-v2;
07System.out.println(v1+" - "+v2+" = "+v); v=v1*v2;
08System.out.println(v1+" * "+v2+" = "+v); v=v1/v2;
09System.out.println(v1+" / "+v2+" = "+v);
10}
11}

GIF
coding results, will produce a number with fractional numbers (float / double) of the accretion process, subtraction, division, multiplication.

Berlangganan update artikel terbaru via email:

0 Response to "Use of variable JAVA"

Iklan Atas Artikel

Iklan Tengah Artikel 1

Iklan Tengah Artikel 2

Iklan Bawah Artikel