CODE, COMPILE & RUN…REPEAT!


Sept 17

5 min read

by Nicole Hargrove


Yes these three words sum up what I have been focused on for the last couple of weeks. I have been working on Java training content for Strategio Technologists. DevOps Engineers have broad, cross functional skills. The truth of the matter is that in order to add even greater value to our teams, this is another skill that we should acquire.

It amazes me how Java is STILL one of the top programming languages to learn. I remember learning Java on the job as one of my first software engineering roles at Big Blue. Java is STILL around because for decades it has proven itself to be robust and secure, write once, run anywhere (WORA) and is used in several enterprise applications. Trust me it is worth taking the time to learn! Oracle just released Java 17 Long Term Support (LTS) on September 14, 2021. As I was working, I took some time to attend Oracle Developer Live Java Innovations to hear all about it.

OK to truly learn Java or any programming language, you have to take the leap and jump in with both feet….or in this case hands lol.

Here are few tips to get you started:

  • Use an Integrated Development Environment (IDE). OK I know some people advocate for using their favorite text editor and banging out the code. More than likely when you work for a company, you will be using an IDE. IDEs provide different features but the main features to look for are code-assist, editors, debugger, compiler and integrations with version control (Git/GitHub/GitLab), build automation(Ant/Maven/Gradle), testing tools (JUnit/Selenium) and application profiling for viewing performance, memory usage, potential memory leaks and threading. Eclipse IDE and IntelliJ IDEA are the two I have been using.

  • Understand the scenario and outline it before you start coding. Outlining is nothing more than creating an algorithm (a set of instructions) to solve the problem. We know there are multiple ways to solve a problem. There are several books that are written about Java Design Patterns.

  • Code, Compile and Run! These three words sum up the life cycle of a Java program. Code the program creates the source code (a .java file), compiling the code creates bytecode (.class file) and running takes the bytecode and converts it to machine code which computers understand. Look up tutorials online and start digging in!

Let me start you off by going through the process with the rite of passage program to all programming languages: Hello World lol!

Scenario: Create a Java application that will display Hello World to the user.

Outline:

This outline process can also be captured in your IDE as a skeleton.

1) Create a Class with a public static void main method.

2) Hello World is a String.

3) Can I use an existing class to display this String? This is when searching the documentation and of course Google it comes in handy. It is a good practice to get familiar with the existing classes that are provided so you don’t waste your time reinventing the wheel. Also design reviews will help ensure that you have sound code.

Below is the working code for the Hello World Application and the result.

  • The main() method is required and can be set in all Java code. The Java compiler starts executing the code from the main method.

  • The Java program class name and file name must match.
  • {} curly brackets or braces denote the beginning and end of a code block.
  • // means a single-line comment and /* and */ (not pictured) are used for multi-line comments.

Example for multi-line comments:

/* Is used for the beginning instead of just forward slash

Add an*. Once the comments are done end with */

  • Semi-colon (;) is required at the end of the code statement.
  • System.out.println() dot notation (.) is used to access the System class’s methods. This is used to print out whatever is between the double quotes “”.

OK see how easy that was! I hope this ignited a spark in you to learn more.

Remember SHARING KNOWLEDGE is POWER and KEEP Learning! BTW in America it is football season and I am a part of the Baltimore Ravens Flock aka Nation lol so my mini me will be sporting her Ravens gear for the rest of the season!!!! Carry on! lol