2011-08-04

How to write hello-world in both Java and C++

This blog post explains hwo to write a hello-world program which compiles in both Java and C++.

The following solution makes use of the language difference that //...\ continues the one-line comment in C++, but not in Java.

//\
class t{public static void main(String[]a){System.out.print/*
#include<stdio.h>
int main(){if(1){return!printf//*/
("Hello, World!\n");}}

No comments: