Testing of the code snippets

1 min read

๐Ÿš€ Hello World Example in Different Languages

This example demonstrates how to write a simple Hello World program in multiple programming languages: C++, Java, and Python. Use the tabs below to view the implementation in your preferred language.

%[Code Group]

// C++ Hello World
#include <iostream>
using namespace std;

int main() {
    cout << "Hello, World!" << endl;
    return 0;
}
// Java Hello World
public class HelloWorld {
    public static void main(String[] args) {
        System.out.println("Hello, World!");
    }
}
# Python Hello World
print("Hello, World!")

%[End]


๐Ÿ“„ Explanation

  • C++: Uses the iostream library to output text to the console.

  • Java: Uses the System.out.println() method inside the main function.

  • Python: A simple one-line print() function.


โœ… Try it out:
Paste the code into your Hashnode CMS editor and preview it to see the toggleable code tabs in action!