What is the difference between Java and JavaScript in the context of web development?

Java is a statically typed programming language commonly used for backend development, while JavaScript is a dynamically typed language primarily used for frontend development. In the context of web development, Java is often used for server-side processing and handling business logic, while JavaScript is used for client-side interactions and dynamic content on web pages.

// This is a PHP code snippet, not Java or JavaScript
// Java example:
// Backend processing
public class HelloWorld {
    public static void main(String[] args) {
        System.out.println("Hello, World!");
    }
}

// JavaScript example:
// Frontend interaction
document.getElementById("demo").innerHTML = "Hello, World!";