Java Concept

Sun Microsystems created the Java language. Java is a case-sensitive programming language, like C++. Java is an Object-Oriented Programming (OOP) structure. Java is a class-based programming language.
Example with a simple Java program
Open Notepad and type in this program, maintaining the upper and lower case, because Java is a case-sensitive programming language.
  1. class Krishna {
  2. public static void main(String[] args) {
  3. System.out.println(“("Welcome to Basic concept of Java");
  4. }
  5. }
Welcome to the Basic concept of Java
basic concept of java
Now we can create a program in Java, without a main() and terminate the curly bracket, with a semicolon ({;};)
The following is an example:
  1. class Krishna {
  2. ;
  3. static {
  4. ;
  5. System.out.println("Welcome to Basic concept Of Java");
  6. };
  7. };
See that this program that has no errors, when compiled and run.
See the following output here:
simplef java program
Java has more packages like.
  1. import java.util.Scanner;
  2. import java.awt.*;
  3. import java.applet.*;
AWT is the Abstract Window Toolkit.
The following is an example of a packages program:
  1. import java.util.Scanner;
  2. class Oddeven {
  3. public static void main(String[] args) {
  4. int a;
  5. System.out.println("Please enter the number ");
  6. Scanner in = new Scanner(System.in);
  7. a = in .nextInt();
  8. if (a % 2 == 0) {
  9. System.out.println("this number is even num");
  10. } else {
  11. System.out.println("this number is odd num");
  12. }
  13. }
  14. }
Use the same process as above, for the first Java program and for other Java programs. Compile and run it.
When you compile the same with the same class name load the .class name file. Then you can run using the command only.
java Oddeven //java and class name only.
See the following image with the program and output in “cmd”:
program and output in cmd
  • After run show message
  • Please enter the number
  • User enter number like 2
  • Show message like
  • this number is even num
  • And again run show message
  • Please enter the number
  • user enter like 5
  • Show message below
  • this number is odd num
Next time, I will include some more interesting commands. Thank you! I Hope this is helpful for you. Enjoy :).
Thanks in advance.