Java is a object-oriented programming language whereas c++ is structural and partial
object-oriented programming language . My first program in java.
The syntax of Java is
As Java is case sensitive language you should be carefully in upper case & lower case letters
simple program in java
To execute :
1. javac sample.java
2. java sample
Output:
Hello world
Explanation of the above code:
1st line : In java everything should come inside class
2nd line: The program execution will start after the "main"
object-oriented programming language . My first program in java.
The syntax of Java is
public class classname {
public static void main (String args[]) {
ur statement ;
}
}
As Java is case sensitive language you should be carefully in upper case & lower case letters
simple program in java
Save the above code as sample.java
public class sample {
public static void main (String args[]) {
System.out.println("Hello world");
}
}
To execute :
1. javac sample.java
2. java sample
Output:
Hello world
Explanation of the above code:
1st line : In java everything should come inside class
2nd line: The program execution will start after the "main"
0 comments:
Post a Comment