
What is Java?

Java is a programming language and computing platform first released by Sun Microsystems in 1995.
Java is a widely used object-oriented programming language and software platform that runs on billions of devices, including notebook computers, mobile devices, gaming consoles, medical devices, and many others.
It has evolved from humble beginnings to power a large share of today’s digital world, by providing the reliable platform upon which many services and applications are built. New, innovative products and digital services designed for the future continue to rely on Java, as well.
“Java creates an environment for code to run regardless of the operating system, so software developers that write code in the Java programming language can run their programs on pretty much any operating system, including Microsoft Windows, Apple OS X, Linux, and UNIX variants,”
What are the different Applications of Java?
- Mobile Applications.
- Desktop GUI Applications.
- Web-based Applications.
- Enterprise Applications.
- Scientific Applications.
- Gaming Applications.
- Big Data technologies.
- Business Applications.
- Distributed Applications
- Cloud-Based Applications
What is the difference between Java and JavaScript?
Key differences between Java and JavaScript: Java is an OOP programming language while Java Script is an OOP scripting language. Java creates applications that run in a virtual machine or browser while JavaScript code is run on a browser only. Java code needs to be compiled while JavaScript code are all in text.
Popular Examples
Java Program to Check Prime Number.
Java Program to Display Fibonacci Series.
Java Program to Create Pyramids and Patterns.
Java Program to Reverse a Number.
Main.java
Create a class named “Main
” with a variable x:
public class Main {
int x = 5;
}
Example
Create an object called "myObj" and print the value of x:
public class Main {
int x = 5;
public static void main(String[] args) {
Main myObj = new Main();
System.out.println(myObj.x);
}
}
Example
Create two objects of Main:
public class Main {
int x = 5;
public static void main(String[] args) {
Main myObj1 = new Main(); // Object 1
Main myObj2 = new Main(); // Object 2
System.out.println(myObj1.x);
System.out.println(myObj2.x);
}
}