Open In App

Java File Format | .java Extension

Java is a high-level, object-oriented programming language. A source code file written in the Java programming language is saved with the extension .java. .Java file extension typically contains Java code that can be compiled into bytecode and executed on the Java Virtual Machine (JVM). The Sun microsystem developed it. It is a platform-independent programming language. It is used to develop Android applications, web applications, artificial intelligence, cloud applications, and much more.

Brief History

Features of the java

Syntax of Java




/*package whatever //do not write package name here */
 
import java.io.*;
 
class GFG {
    public static void main (String[] args) {
        System.out.println("GFG!");
    }
}

Explanation:

Output



GFG!

Advantages of Java

Disadvantages of Java

Example Code: A simple code to add two numbers




import java.util.Scanner;
 
public class SumCalculator {
    public static void main(String[] args) {
        // Create a Scanner object to read user input
        Scanner scanner = new Scanner(System.in);
 
        // Prompt the user to enter the first number
        System.out.print("Enter the first number: ");
        int num1 = scanner.nextInt();
 
        // Prompt the user to enter the second number
        System.out.print("Enter the second number: ");
        int num2 = scanner.nextInt();
 
        // Calculate the sum of the two numbers
        int sum = num1 + num2;
 
        // Display the result
        System.out.println("The sum of " + num1 + " and " + num2 + " is: " + sum);
 
        // Close the Scanner to avoid resource leak
        scanner.close();
    }
}
 
}

Output:

The sum of 5 and 6 is: 11

Conclusion

In conclusion, Java stands out as a versatile and powerful programming language that has significantly shaped the world of software development. Its “write once, run anywhere” philosophy, object-oriented nature, and extensive library support have made it a favorite among developers. Java’s portability, robustness, and scalability have contributed to its enduring popularity and widespread adoption in various industries. 
 


Article Tags :