Yes, we talk about coding a LOT.
We’ve dissected coding languages for kids.
We’ve defined coding terms.
We’ve even talked about how children can start coding.
And that’s why I’m back, again.
Only this time, it’s less about me motivating you or trying to persuade you that yes, coding is something that should be a focus for your child, and more about helping your child take action within a specific coding discipline—Java coding.
What should you know about Java coding, specifically? How can kids get started making their own game or application?
The goal of this post is to get you and your student thinking—does Java coding sound like something they'd want to explore further?
Of course, after reading through, there will still be some learning holes that need filling.
What follows, though, should be more than enough to nudge aspiring coders in the right direction, should they choose to do so.
Why Java Coding?
Java is a powerful, multi-platform programming language used for a number of professional and commercial applications—including every Android app and even the Android operating system itself!
With Java, kids can learn to make a tic-tac-toe game with a win algorithm, a top down shooter, or an endless runner!
What else uses Java?
Minecraft—ever heard of it?
Well, Minecraft was completely developed in Java by Markus Persson. In case you’re new to the game, players build with different blocks in a 3D, procedurally generated world. (Minecraft also has a number of educational benefits!)
With about 75 million players monthly, Minecraft is still one of the biggest games in the world, with Markus Persson considered to be one of the most successful game developers of our time.
Did you know that Gmail is currently the most popular email service available?
Developed by Google, Gmail was created in Java because Java has a great performance rate and a good framework for web.
Java is also famous for WORA which stands for "write once, run anywhere." This cross-platform benefit allows coders to build and run Java programs on multiple different platforms.
Do you tweet?
Twitter, a popular social media platform, uses Java as well for scalability. Not to mention that Java is extremely portable—Java programs can be run on a number of different platforms, making it a great language to use.
The bottom line? You can use Java to make a wide range of games and programs for millions of people!
What are some examples of Java concepts?
2D jump physics
To simulate gravity, kids can code their own physics!
They can manually check and set the height of a character to simulate a jumping motion, and in order to achieve a smooth jump, they’ll need to keep track of the frames in the game. Sound fun?
A win algorithm can do things like check a board in tic-tac-toe to see who has won.
This can be achieved with a “for loop” and “if statements” (more on each to follow!).
Complex data structures
Can you imagine managing the large music library at Spotify?
With Java, kids can learn how to code a data structure that can hold the queued music on a Spotify playlist!
A basic type of AI in games is one that finds and seeks the player.
To achieve this, coders must get the enemy object and then move it towards the player object.
In addition to randomly spawning enemies in a game, you can also increase the difficulty by upping the spawn rate.
Take a look!
What might you need to know to get started?
To start with Java coding, kids can use the Java SDK, as well as IntelliJ for writing and running code. (You can download the community version of IntelliJ IDEA here.)
Important: This information is intended for parents to share with their kids. Kids, if you’re reading this, always obtain parent permission before downloading and executing anything on your computer.
All Java code is contained within class files, so, your child will need to create a class file in their newly-created project.
Important: Class names should be capitalized, and each new word in the title should also be capitalized. The names cannot contain spaces.
Example of a correctly-named class: “AdventureGame”
Before your child can begin coding, they’ll need to add a method inside of the class, which is the first bit of code that’s called when you run your program. Think of it like a starting point for the rest of the code!
To create a main method in IntelliJ, underneath “public class [ClassName]” your child can type “psvm” and then press the tab button.
(psvm is a shortcut that creates the main method.)
Other basics to get familiar with
Beyond the points above, there are a handful of basics your child should start getting familiar with.
Understanding the info below won’t make your child a coder, but kids will find it difficult to move forward in the learning process without these details.
A variable stores information about a program while it's running.
Example: In an RPG (a type of video game), a character's name, level, and hit points are all stored in their own variable.
Any time your child is playing a game and they level up (or take damage), a variable changes to reflect what happened.
To use a variable, a coder must declare the proper variable type:
Integers: An integer is a type of variable and represents a whole number. For example, -17, 4, 0, and 42 are all integers. You declare an integer in Java using the “int” keyword.
Doubles: A double is a number that can have a decimal. For example, -12.5, 4.0, 0.001, and 4.2 are all doubles. You declare a double in Java using the “double” keyword.
Strings: You use a String to store text. For example, "carrot," "apple pie," "pear," and "orange juice" are all Strings. You declare a String in Java by typing “String” followed by the variable name.
Important: It's considered good practice to declare all variables at the beginning of the code. When everyone codes this way, they know exactly where to look to find them!
Operators perform mathematical calculations while a program is running.
Example: Say, for instance, if a character earns experience, the action needs to be added to the total experience count. If an arrow hits an enemy, the damage it takes needs to be subtracted.
So, operators are used for whenever a value needs to be changed.
Multiple operators can be performed at once, and Java arithmetic operators follow the mathematical order of operations
Some basic operators and their order of precedence are listed in the table below.
An if statement allows coders to execute code if some condition is met.
Example: When a monster is attacked in an RPG, they’ll need to check if that monster has been defeated.
Using if statements, kids can write a program in which they determine if a character is strong enough to slay a dragon.
A for loop runs a section of code repeatedly until a condition is met, like a while loop. However, they use a different syntax and are useful when you're using an array.
Example: In an RPG, a player's inventory could be stored as an array of strings. While exploring a dungeon, they encounter a locked door—a for loop can be used to determine if the player is carrying a key to the door.
The programs explained so far have run in a straight line from start to finish. In an adventure game, once a player makes a choice, there is no way they can turn back and make another choice.
A while loop is code that repeats itself based on a condition.
Example: A while loop can continue to run until monster health is equal to 0. Now, players will continue to descend into the depths of the dungeon until they run out of health!
Ready to put it all together?
With the above basics, you and your kids should have a better idea on whether or not embarking on an adventure into the world of Java coding fits their interests.
So, next steps?
Attending a summer coding camp is a great option, allowing students to dive into the details and build a lifelong passion for tech, like Java, alongside new friends in a pressure-free, creative environment. Online coding courses offer much of the same, but from the comfort of home.
Have a kid who enjoys something like playing Pokémon? Maybe building a text adventure RPG is in their future. If they are interested in social media, perhaps they can try to recreate an algorithm for different user search functions.
With hands-on exposure to Java fundamentals and the opportunity to dig deep into programming logic, coding camps help students build the confidence needed to keep learning long after summer ends.