Wednesday, 27 December 2017

1.4 Additional Knowledge

1. Class name can be different as the file name.

class A{
    public static void main(String args[])
    {
         System.out.println("Test");
    }
}

Save it as B.java
after compiling B.java  -----  javac B.java
you'll get a class file with name A.class. To run this code you have to write java A instead of java B.

2. Comments

/*
Multiple line comments
Multiple line comments
*/

// Single line comment


3. Concatenation operator = "+"

int a,b,c;
a=5;
b=5;
c=a+b;
System.out.println("Addition of "+a+ " and "+b+" is "+c);

4. printf in java
System.out.printf("Addition of %d and %d is 5d",a,b,c);


No comments:

Post a Comment