28 Ott 2002
Costruzione di Interfacce - Paolo Cignoni
Hello World
[Hello.java]
package
hello; // says that we are part of a package
named hello
public class Hello // declare a class called Hello
{
public
static void main(String args[]) // declare the function main
// that takes an array of Strings
{
System.out.println("Hello world!"); // call the static method
// println on the class System.out
// with the parameter "Hello world!"
}
}
[Hello.C]
#include
<iostream> // include declarations for the "cout" output
stream
using namespace std; // the cout stream is in the
std namespace
// this tells the compiler to look in the std
// namespace, you can also write std::cout
int main(int argc, char
*argv[]) // declare the function main that
// takes an int and an array of strings
// and returns an int as the exit code
{
cout
<< "Hello world!" << endl; // this inserts "Hello
world!"
// and an newline character into the cout
// output stream
}