Javafun

tree

Christmas
public class Javafun
{ public static void main(String[]args)
{int a = 0;
while (a<1000000)
{a++;
System.out.println(a);
}}}
 
Originally posted by chevy
how do I try it ?

You must have the Developer tools installed, or the java compiler.

Create a text file with that code.
Save as Javafun.java
In the terminal, navigate to the directory containing the java file(cd path_to_file)
type in javac Javafun.java to compile to java bytecode.
type "java Javafun: to run it, and be prepared to see it print out the numbers 0 to 999999

You must note the file name. Java files must have the file name that exactly matches the class name.
 
You don't need the developer tools to do this. The Java compiler is part of the standard system.
 
Here's the same program written differently:

public class Javafun
{
public static void main(String[]args) {
for (int i = 1, i <= 1000000, i++) {
System.out.println(i);
}
}
}
 
Yeah, so? I could show you the Javascript way, but I'm not going to waste my (or your) time.

But if anyone wants a surefire script to lock up their browser...
 
I could show you a Java program that would do more than lock up your browser... I could show you one that actually does something useful!
 
Erm.. I think those should be semicolons in that for statement..

public class Javafun
{
public static void main(String[]args) {
for (int i = 1; i <= 1000000; i++) {
System.out.println(i);
}
}
}
 
Back
Top