Java Reference
In-Depth Information
If I compile and install it with ./ , stop the server and restart it, and then
run the /simple command in Minecraft, my test with 10 years gets me
315,360,000 seconds:
$ cd Desktop
$ cd Simple
$ ./
Compiling with javac...
Creating jar file...
Deploying jar to /Users/andy/Desktop/server/plugins...
Completed Successfully.
Did you get the same answer? You can see the full source code that I put
together at code/Simple2/src/simple2/ .
Note that there are a couple of different ways to accomplish even this simple
function. There usually isn't just one “correct” way to write code.
That's a good start, but there's more to Java than just variables and functions.
The Java language has certain special keywords that you can use to direct
how and when to run various bits of code. We've seen some of these already,
including public and static , which describe the code. Now we'll look at keywords,
including if , for , and while , that let you control how code is run.
Use a for Loop to Repeat Code
Computers are much better at repetitive tasks than humans are; you can tell
the computer to do something ten times in a row and it will do exactly that,
ten times, a hundred times, a million times, whatever you want. One way to
do the same thing a bunch of times is to use a for loop. for is a Java keyword
that lets you loop over a section of code a fixed number of times.
Search WWH ::

Custom Search