O'Reilly logo

Learn to Program with Minecraft Plugins, 2nd Edition by Andy Hunt

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Organize Instructions into Functions

So now that you can store all kinds of data in variables, next you need to learn how to write instructions to do fun actions with all that data, from printing messages to flinging flaming cows in Minecraft.

As you’ve seen, you can also tell Java to do things. In Java, you organize lines of code (instructions) inside a pair of curly braces, like { and }. You give that section of code a name, and those instructions will be run in order, one line after another. We call that a function (sometimes we’ll call it a method; for now they mean mostly the same thing).

Why do we bother with functions at all? Couldn’t we just have one big list of instructions and be done? Well, yes, we could, but it can get very confusing ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required