Tutorials

  • Conditions in Java

    You will find conditions in Java familiar if you are used to using boolean conditions in C/C++. However, noticed that I said boolean conditions. That is because Java wants boolean conditions, those that generate a true or false answer, instead of the C/C++ conditions which actually look for an integer value. Notice the following below…

  • Java Variables

    Inside of a method, like our main method, we might want to create some variables for use. Java gives us numerous primitive data types that we can use, and within a method, we declare and use them, just like we would in C/C++. Comments You might have noticed the comment above. Comments in Java are…

  • Java’s main Method

    Just like in C++, each executable Java project should have a main method. This isn’t just the “main” method that is run, but an actual method called main(). If you look at the previous page for creating a file, we can start from there. This will be a little different from the C++ main method,…

  • The Bubble Sort

    The Bubble Sort is one of the simplest sorts you can write, from a developer’s perspective. Unfortunately, it is one of the slowest to run from the computer’s perspective. A bubble sort works on the following idea. Given a list of values, start at the top value and look at the next value. If the…

  • Binary Search

    If our data is pre-sorted then a binary search starts to make a lot of sense. It is like the guessing game we mentioned earlier where you need to find a number between 1 and 100. No one asks for 1, then 2, then 3… until they find it. Instead we ask for the mid…

  • Brute Force Searching

    Now in some cases, we’ll use a brute force method of searching. This is slow and inefficient from a run-time perspective. However, it is relatively fast to write. With a brute force search, you scan through every item in a list until you find the element. Why use Brute Force As you can imagine, scanning…