Pages

Thursday, October 18, 2018

So You Want to Learn Java?

Good for you!  Java is a great place to start learning programming, as it is one of the most popular object-oriented programming languages.  Other object-oriented languages include C#, PHP, Python, and C++.  According to Java T Point (n.d.), object-oriented languages allow a developer to design programs through the use of classes and objects.  Objects are real-world entities that exhibit both states and behaviors (Oracle, 2015).  For example, a dog is an example of an object.  A dog has states such as breed, size, age, etc.  A dog also exhibits behaviors, such as barking, sleeping, running, etc.  New objects are built from the blueprints of a class.  A class contains objects with similar states and behaviors.  For example, a shitzu, a pug, and a german shepard might all belong to the class “dogs”.  The use of objects and classes “simplifies software development and maintenance” (Java T Point, n.d.).

There are a number of reasons why object-oriented programming languages are so widely used.  Most of them can be described by the 4 principles of object-oriented languages: inheritance, polymorphism, abstraction, and encapsulation.  Inheritance is the idea that similar objects can inherit states and behaviors (Oracle, 2015).  In the example above, since a shitzu, a pug, and a german shepard all share similar states and behaviors, each of these objects might fall under a superclass called dogs.  The concept of inheritance allows for code reusability, which simplifies software development.  Polymorphism refers to “multiple methods with the same name, but slightly different functionality” (Raymondlewallen, 2005).  Again, this allows for code reusability since a method, which is like a call to action on an object, can be a modified version of a pre-existing method, rather than requiring a whole new set of code.  Abstraction describes the act of hiding details related to processing (Java T Point, n.d.).  This simplifies the interface and allows code to be more readable.  Lastly, encapsulation refers to the fact that the code is organized into units, such as objects and classes (Java T Point, n.d.).

So how do you get started with Java?  One of the best resources I’ve found is The Java Tutorials.  This resource provides not only the basics of Java, but also how to install the necessary software, and a step-by-step approach to write your first program, “Hello World.”  While this program can be written in a number of different IDE’s (integrated development environments), Oracle recommends the NetBeans IDE.  For steps to install Java, the NetBeans IDE, and write the “Hello World” program, click here.  It is important to note that NetBeans does not support Java JDK version 9 or above, so it is recommended to install JDK 8.  If you do decide to follow these steps, please leave me a comment describing your experience.  Have fun my fellow coder!

Resources:

Java T Point. (n.d.). Java OOPs concepts. Retrieved from http://www.javatpoint.com/java-oops-concepts

Oracle. (2015). "Hello World!" for the NetBeans IDE. Retrieved from https://docs.oracle.com/javase/tutorial/getStarted/cupojava/netbeans.html

Oracle. (2015). The Java tutorials. Retrieved from http://docs.oracle.com/javase/tutorial/index.html

Oracle. (2015). Lesson: Object-oriented programming concepts. Retrieved from http://docs.oracle.com/javase/tutorial/java/concepts/index.html 

Raymondlewallen. (2005, July 19). 4 major principles of object-oriented programming.  Retrieved from http://codebetter.com/raymondlewallen/2005/07/19/4-major-principles-of-object-oriented-programming/