Java Constructors

Each object has a special method called a constructor. The constructor can be overloaded as necessary. Typically, you will have a default constructor (sometimes called a no-arg constructor), where no parameters is passed to the constructor. This special method is used to constructor an object when it is created. It is very similar to a…

Overloading Java Methods

As was mentioned briefly in talking about Java Instance Methods, you can overload a Java method, just as you would overload a C++ function/method. (C doesn’t allow for overloading, only C++). Since there is no method prototype, it is easy to just write your new method. I like to group my overload methods together, so…

Class Methods in Java

In object oriented programming, you consider the object which you are programming about, for example, a car. You then consider the attributes about the object, for example, the make, model, color, year built, etc. You also have consider the operations of the object. i.e. What can it do? A car for example could turn on…

Static Methods in Java

Static methods in Java work on the same basic idea of static functions in other languages like C/C++. The idea is that sometimes you have a function that either needs to be shared between instances, instead of tied to a specific instance, or to be used without needing to create an object from the class…

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…