Importing a Package

Importing a package allows me to import a class, or set of classes into my application that I can use. (These will be outside of the package that I create for my own project.) These packages act like libraries in other languages where a lot of work might be done for you already, and you…

Java Arrays

Arrays in Java are similar to C/C++ arrays, however there are some special unique things about them which make Java Arrays a little easier to work with in my opinion. Like in C/C++ you can have single dimensional or multidimensional arrays. Advantages to Arrays Like a C/C++ array, the array in Java is a contiguous…

Loops in Java

Loops in Java work similarly to how you remember loops in C/C++ most likely. You have your counting loop (for), as well as your pretest conditional loop (while), and the conditional post test loop (do-while). Each of these work the same way you would expect them to in C/C++. For Loop The for loop is…

Console Output in Java

Compared to some languages, you might find writing out basic output in Java…well…overly complex. However, once you understand Java, you will see that it is complex, but for a reason. Let’s first consider some languages you might have already seen. Each one of these prints “Hello World” to your console window. So how does Java…

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,…