Java Programming

For a good four years or so, I had a Java tutorial for beginners hosted on CodinGame. As of 2026, CodinGame has announced that "Playgrounds and the tech.io platform are currentlyh entering deprecation, and will be partially or completely removed in the future." Here is the link: https://www.codingame.com/playgrounds/64843/beginner-python-concepts/intro

As of June 21st, 2026, I have copied the contents of that playground and pasted it here as comments. I intend on formatting and adding it all here for (hopefully) a more persistent and lasting platform.

1/12 Cover Page ----------------------------------------------------------------------------------------- UNDER CONSTRUCTION Welcome to Beginner Java Concepts! And welcome to the wonderful world of Computer Science! So, first off, this playground is "under construction." That means that I'm still working on a few things, but there is still value in this guide! The main thing I'm working on is adding interactive examples. For now, you can copy the code snippets and run them in your local development environment. It's a good idea to have a local development environment for any coding language you want to be familiar with. I'm also still working on more examples of algorithms and more complex concepts. For anyone wanting to get into the tech industry, I recommend checking out my Beginner Python Concepts playground as well. It's very useful to be able to translate coding concepts into multiple coding languages. Integrated Development Environment (IDE) For just starting out, I recommend using Eclipse for your Java IDE. You can download your own copy for free here: https://www.eclipse.org/ide Until I configure the interactive examples, you can copy and paste code into your Eclipse project. For how to install and use Eclipse, you can search YouTube here: https://www.youtube.com/results?search_query=how+to+install+and+use+eclipse+for+java My Existing Java Resources CodinGame is just the most recent installment in my journey to becoming a Computer Science Educator. For additional tutorial resources, look at my profile and follow the links! If you like my work, consider subscribing to my YouTube channel and / or following me on the Twitch! I'm an affiliate on Twitch, so I actually earn revenue from people watching the ads on my streams (live and past streams, but only on Twitch) and buying subscriptions. YouTube I'm still far off from, but I could realistically become a partner within a year or so. However, this is all done in an effort to provide free Computer Science education to anyone willing to learn. I used to tutor freshmen and sophmore CS students at CSU and love being able to introduce others to the wonderful world of CS! My end goal was to become a professor or teacher in Computer Science. With wonderful tools like CodinGame, Twitch, Codepen, Replit, and YouTube, I'm well on my way! And by that, I mean that my reward is the intrinsic value of helping others. Still, I'm not gonna be mad if you kickback some in appreciation. Twitch - algore719 https://www.twitch.tv/algore719 YouTube - a-Rye https://www.youtube.com/channel/UCqfrRoUg5dtY-i5xZrB0ixg 2/12 Intro ----------------------------------------------------------------------------------------- Java Before we get into the specifics of Java programming, it's important to understand what it is you're really doing. All computer programming is translating something that we can read into something computers can read. Computers operate all in 1's and 0's. They will do exactly what you tell them to do, no more, no less. You need to be very specific when telling a computer what to do. You can't assume that the computer will know what you're talking about. Take packing for a trip as an example. If you were telling a person how to pack luggage, you could just list some items and be done. However, if you were telling a computer, you would need to provide all the information. What piece of luggage should you use? How many pieces of luggage? Are we bringing liquids? What happens when we fill the first piece of luggage? This is an intentionally vague example. To relate this to something you would actually do for a job in the tech industry, think about preparing reports based on certain data. You would need to tell the computer where to find the data, how to format the report, where to send the output, and plenty in between. Maybe you also need to calculate some values based on some data for the presentation. Or, maybe you're building an app for a company. Or maybe you're building a video game. Regardless of what you want to do with Computer Science, you'll need to start at the basics. Programming Concepts in a Nutshell All computer programming languages require you to know a few certain concepts. These are concepts like Input / Output, Primitive Variables, Comments, Control Flow, Loops, and Objects. Then, it's a matter of tying it all together into a functioning piece of code! 3/12 Hello World ----------------------------------------------------------------------------------------- Hello World! Hello World is often the first program you learn when learning a new language. The concept is to demonstrate using the output stream to see data in the console. Specifically, we're seeing the String value between the double quotes (" "). public static void main(String[] args) { System.out.println("Hello World!"); } Methods This early program also demonstrates an example of a method. Specifically, this is the Main method that is usually included in smaller projects. You can also have a Main class file instead of having Main methods in every class file. Methods are sections of code that can be called or invoked. It's good practice to separate out specific tasks into their own methods. There are also several built-in methods that come included with Java. When in doubt, try using searching "Java" and specific keywords online. Often, you'll find that someone already built a tool you can use in your own code. Keywords / Reserved Words There are certain keywords in Java that are reserved to serve a specific purpose. In the example above, the words public, static, void, String[], system, out, and println are all reserved to mean specific things. "args" is commonly used, but is really only a variable name that can be changed. Public refers to the the availability of the file. Think of permissions to view based on being either "public", "protected", and "private". We won't worry too much about this in the beginning, but it's something to be aware of. Static is related to memory management and needing to create objects or not. Don't worry about this either for now, just know that it needs to be included when defining methods. Void refers to what type of data is returned from this method. You will need to make sure that you use the correct label for your method. If you don't need to have anything returned, use the "void" keyword. Otherwise, this could be "int", "float", "double", or any primitive variable types. This can also be objects like "String", "ArrayList", or any object. 4/12 Comments ----------------------------------------------------------------------------------------- Comments Comments are text that is ignored by compilers and are very useful in programming. You can use comments to explain your code to others, debug, and even layout a blue print for building your code (psuedocode). // This is a single line comment. /* This is a multi line comment */ Comments can be used to describe sections of your code. // This is the main method. It prints the string "Hello World" to the console. public static void main(String[] args) { System.out.println("Hello World!"); } Comments are also useful when debugging your code. public static int add(int num1, int num2){ return num1 - num2; } public static void main(String[] args) { // I should be getting 8...but I'm getting 2? System.out.println(add(5,3)); } 5/12 Primitive Variables ----------------------------------------------------------------------------------------- Primitive Variables Primitive Variables are simple, single value data that we store for later use. In Java, you need to specify the type of variable whenever you declare a new variable. However, Java is more forgiving with print statements and variable types. The types of primitive variables are: int myInt = 1; float myFloat = 1.0f; double myDouble = 5.00; char myChar = 'A'; boolean myBoolean = true; System.out.println("My int is: " + myInt); System.out.println("My float is: " + myFloat); System.out.println("My int is: " + myDouble); System.out.println("My int is: " + myChar); System.out.println("My int is: " + myBoolean); Scope Scope refers to whether a variable is able to be used in different parts of the code. This can also be thought of as relevancy. When declaring variables, you can either declare global or local variables. Declaring a variable globally means that you are able to use it throughout the rest of your class file. Local variables are declared, used, and only available in the methods which you declared them in. 6/12 Objects ----------------------------------------------------------------------------------------- Objects Strings are often lumped in with primitive variables, but they are actually what we consider "objects." Objects are more complex variables that are capable of storing multiple values. In the case of strings, you're storing and using an array of chars (characters or letters). You can use arrays to store all the types of primitive variables. Constructors For any object in Java, it needs a Constructor to build it to specifications. Arrays Arrays are groups of variables. As mentioned above, Strings are a good example of an array of chars. The indexing for arrays starts at 0. Think of indexing as how many spaces away from the initial space are we. At index 0 of the string "Hello" is 'H'. Also, notice how I used double quotes for multiple chars and single quotes for a single char. In Java, arrays need to be declared with a finite length. ArrayLists Array lists are more complex types of arrays. They are dynamically sized, so you don't have to worry about it filling up and causing an error. However, this adds to the overhead. This means that by calculating a new size based on how large the current array list is becoming costs computational power, and time. 2D Arrays One of the best examples of a 2D array would be an image. An image file has a width and a height, then is filled in with pixel values. This forms a 2 Dimenstional grid. Binary Search Trees Binary search trees are a tad complex, but worth understanding. The idea is to sort data and then use a sorted structure to cut down on how many items need to be searched before the desired data is found. Graphs Graphs are much more complex ways to store data. However, this complexity leads to being very dynamic and efficient. Graphs consist of nodes and edges that connect those nodes. Each node will have a list of the edges it has connecting it to other nodes. 7/12 Control Flow ----------------------------------------------------------------------------------------- Control Flow public static char grade(int score) { if(score >= 90) { return 'A'; } else if(score >= 80) { return 'B'; } else if(score >= 70) { return 'C'; } else if(score >= 60) { return 'D'; } else{ return 'F'; } } Switch Switch statements take an input and compare that with different "cases." Depending on which case the input matches, different lines of code will execute. The keyword "break" is used to make sure that only those lines are executed. If you want multiple cases to execute, simply remove the keyword "break." Notice there are a couple break statements commented out already. public class lessSimpleSwitch { public static String returnMonth(int numMonth) { String month = ""; switch(numMonth) { case(1): month = "January"; break; case(2): month = "February"; break; case(3): month = "March"; break; case(4): month = "April"; break; case(5): month = "May"; break; case(6): month = "June"; //break; case(7): month += "July"; //break; case(8): month += "August"; break; case(9): month = "September"; break; case(10): month = "October"; break; case(11): month = "November"; break; case(12): month = "December"; break; } return month; } public static void main(String[] args) { String test1 = new String(returnMonth(7)); System.out.println(test1); } 8/12 Loops ----------------------------------------------------------------------------------------- Loops Loops are useful when you want to do the same thing, just many times. If you already know exactly how many times you want the loop to run / iterate, you should use a for loop. If you want the loop to be scalable for varying sizes / iterations, use a while loops. If you want a process to happen once and THEN a loop, use a do while loop. However, do while loops might not exist in other languages. There are ways to simulate a do while loop, as well as simulate any type of loop (and even recursion) with the other types. public static void forLoop(int size) { for(int i = 0; i < size; i++) { System.out.println(i); } } public static int whileLoop(int size) { if(size <= 0) { System.out.println(size); return 0; } while(size > 0) { System.out.println(size); size--; } return 0; } public static int doWhileLoop(int size) { // Error handling for input less than zero -> infinite loop if(size <= 0) { System.out.println(size); return 0; } do { System.out.println(size); size--; } while(size > 0); return 0; } public static int recursion(int size) { System.out.println(size); if(size == 0) { return 0; } else { return recursion(size - 1); } } public static void main(String[] args) { System.out.println("For Loop of 5: "); forLoop(5); System.out.println("While Loop of 8: "); whileLoop(8); System.out.println("Do While Loop of 20: "); doWhileLoop(20); System.out.println("Recursion of 15: "); doWhileLoop(15); } 9/12 Switch Statement Algorithm ----------------------------------------------------------------------------------------- witch Statement Algorithm // Helper method to get an int value from a char. public static int fromChar(char letter) { int returnInt = 0; switch(letter) { case 'a': returnInt = 1; break; case 'b': returnInt = 2; break; case 'c': returnInt = 3; break; case 'd': returnInt = 4; break; case 'e': returnInt = 5; break; case 'f': returnInt = 6; break; case 'g': returnInt = 7; break; case 'h': returnInt = 8; break; case 'i': returnInt = 9; break; case 'j': returnInt = 10; break; case 'k': returnInt = 11; break; case 'l': returnInt = 12; break; case 'm': returnInt = 13; break; case 'n': returnInt = 14; break; case 'o': returnInt = 15; break; case 'p': returnInt = 16; break; case 'q': returnInt = 17; break; case 'r': returnInt = 18; break; case 's': returnInt = 19; break; case 't': returnInt = 20; break; case 'u': returnInt = 21; break; case 'v': returnInt = 22; break; case 'w': returnInt = 23; break; case 'x': returnInt = 24; break; case 'y': returnInt = 25; break; case 'z': returnInt = 26; break; default: returnInt = -1000; } return returnInt; } // Helper method to get a char from an int value. public static char fromInt(int value) { char returnChar = ' '; switch(value) { case 1: returnChar = 'a'; break; case 2: returnChar = 'b'; break; case 3: returnChar = 'c'; break; case 4: returnChar = 'd'; break; case 5: returnChar = 'e'; break; case 6: returnChar = 'f'; break; case 7: returnChar = 'g'; break; case 8: returnChar = 'h'; break; case 9: returnChar = 'i'; break; case 10: returnChar = 'j'; break; case 11: returnChar = 'k'; break; case 12: returnChar = 'l'; break; case 13: returnChar = 'm'; break; case 14: returnChar = 'n'; break; case 15: returnChar = 'o'; break; case 16: returnChar = 'p'; break; case 17: returnChar = 'q'; break; case 18: returnChar = 'r'; break; case 19: returnChar = 's'; break; case 20: returnChar = 't'; break; case 21: returnChar = 'u'; break; case 22: returnChar = 'v'; break; case 23: returnChar = 'w'; break; case 24: returnChar = 'x'; break; case 25: returnChar = 'y'; break; case 26: returnChar = 'z'; break; default: returnChar = '@'; } return returnChar; } // Actual ROT13 encryption method. public static String encrypt(String plainText) { // Declare variables to be used in the encryption process. String cipherText = ""; char newChar = ' '; int charVal = 0; char currentChar = ' '; boolean isUpperCase = false; // Loop through each char in plainText and calculate the encrypted char. for(int i = 0; i < plainText.length();i++) { currentChar = plainText.charAt(i); // Check to see if the char is capitalized. // Set the boolean variable to true if it is. if(Character.isUpperCase(currentChar)) { isUpperCase = true; currentChar = Character.toLowerCase(currentChar); } // Calculate the int value for the new char. charVal = fromChar(currentChar) + 13; //System.out.println(currentChar); //System.out.println("charVal: " + charVal); // If the new value is higher than 26, or higher than our alphabet, // adjust it to be circular. // By circular, I mean wrap the sequence around and start back at // the beginning. if(charVal > 26) { charVal = charVal - 26; } //System.out.println("charVal is now: " + charVal); // Calculate the corresponding char from the int value. // If char is non alpha, no change is needed. if(charVal < 0) { newChar = currentChar; } else { newChar = fromInt(charVal); } // If the plain text char was upper case, make the cipher // text char upper case as well. if(isUpperCase) { cipherText += Character.toUpperCase(newChar); } else { cipherText += newChar; } isUpperCase = false; } // Return the cipherText produced from the plainText. return cipherText; } public static void main(String[] args) { String test = encrypt("This is A NEW test, let's see how this works. Low and HiGh abcdefghijklmnopqrstuvwxyz!?()"); System.out.println(test); String test2 = encrypt("Guvf vf N ARJ grfg, yrg'f frr ubj guvf jbexf. Ybj naq UvTu nopqrstuvwxyzabcdefghijkym!?()"); System.out.println(test2); } 10/12 Data Structures ----------------------------------------------------------------------------------------- Data Structures 236 Previous: Switch Statement Algorithm 11/12 Example Algorithms ----------------------------------------------------------------------------------------- Example Algorithms 12/12 Debugging ----------------------------------------------------------------------------------------- Debugging There are many things that can go wrong when programming. In Computer Science, we call these "bugs." The most basic categories of bugs are Syntax and Logic bugs. In Java, indentation (or any whitespace really) won't affect if your code compiles or not. However, it is good practice to organize your code with proper spacing. Syntax is where you have a typo in your code. This could be forgetting a semi colon (;), curly bracket ({}), or any other symbol required for the code to be compiled. You could be missing a curly bracket: public static void main(String[] args) System.out.println("Hello World!"); } Or missing a semi colon: public static void main(String[] args) { System.out.println("Hello World!") } Or misspelling a keyword: pablic statoc vid main(String[] args) { System.out.println("Hello World!"); }