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 themain
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!