Saturday, December 24, 2016

Printing a Variable

Tags

In Java We Can Print The Value Of Variable by using a '+' symbol like as shown in following program 

Program :


public class JavaApplication1 {

    public static void main(String[] args) {
        int a=15;
        System.out.println("Value Is :"+a);
    }
}


Output:


Printing sum of two variables :


public class JavaApplication1 {

    public static void main(String[] args) {
        int a=15,b=10;
        System.out.println("Sum Is :"+(a+b));
    }
}

Output: