The Wayback Machine - https://web.archive.org/web/20211222022709/https://www.geeksforgeeks.org/difference-between-java-and-javascript/amp/

Difference between Java and JavaScript

In this article, we will know about Java & Javascript, & also see the significant distinction between Java & Javascript.

JavaScript:
JavaScript is a lightweight programming language(“scripting language”) and is used to make web pages interactive. It can insert dynamic text into HTML. JavaScript is also known as the browser’s language. JavaScript(JS) is not similar or related to Java. Both the languages have a C-like syntax and are widely used in client-side and server-side Web applications, but there are few similarities only.

Hey geek! The constant emerging technologies in the world of web development always keeps the excitement for this subject through the roof. But before you tackle the big projects, we suggest you start by learning the basics. Kickstart your web development journey by learning JS concepts with our JavaScript Course. Now at it's lowest price ever!

Features of Javascript:

Example: This is the basic Javascript example. 






<script>
    console.log("Welcome to GeeksforGeeks Learning");
</script>

Output:

Welcome to GeeksforGeeks Learning

Java:
Java is an object-oriented programming language and has a virtual machine platform that allows you to create compiled programs that run on nearly every platform. Java promised, “Write Once, Run Anywhere”.

Features of Java:

Example: This is the basic Java program.




import java.io.*;
  
class GFG {
    public static void main(String[] args)
    {
        System.out.println(
            "Welcome to GeeksforGeeks Learning");
    }
}

Output:

Welcome to GeeksforGeeks Learning

Difference between Java and JavaScript:

Java JavaScript
Java is a strongly typed language and variables must be declared first to use in the program. In Java, the type of a variable is checked at compile-time. JavaScript is a weakly typed language and has a more relaxed syntax and rules.
Java is an object-oriented programming language. JavaScript is an object-based scripting language.
Java applications can run in any virtual machine(JVM) or browser. JavaScript code used to run only in the browser, but now it can run on the server via Node.js.
Objects of Java are class-based even we can’t make any program in java without creating a class. JavaScript Objects are prototype-based.
Java program has the file extension “.Java” and translates source code into bytecodes which are executed by JVM(Java Virtual Machine). JavaScript file has the file extension “.js” and it is interpreted but not compiled, every browser has the Javascript interpreter to execute JS code.
Java is a Standalone language. contained within a web page and integrates with its HTML content.
Java has a thread-based approach to concurrency. Javascript has an event-based approach to concurrency.
Java supports multithreading. Javascript doesn’t support multi-threading.



Article Tags :
Practice Tags :