Baby Java: Exploring, Building, Enhancing, & Fixing Java Apps in Pieces and Baby Steps

Baby Java: Exploring, Building, Enhancing, & Fixing Java Apps in Pieces and Baby Steps

In most things, we need to crawl before we walk, walk before we jog, and jog before we run ...

In this blog we'll leverage the same approach with the beautiful programming language Java.

Enjoy!


My daughter & I at one of our nation's oldest aquariums on Belle Isle.

So let's get started with a very small piece of code, pretty much hello world.
This assumes that you have java installed as well as the java development kit installed.
You can typically get standard, reliable versions from oracle.

This code would need to live in a file named BabySteps.java so that the public class BabySteps will work well with it.

  1 public class BabySteps {

  2     public static void main (String args[]) {

  3         System.out.println("Crawling before walking, walking before jogging, jogging before running!");

  4     }

  5 }


Be careful to ensure that each line of code is perfectly transcribed (i.e. part of line 3 may run onto what appears to be another line but that is really all to be on a single line of code).

You can compile and execute the code with the commands below (for a mac):

clear && javac BabySteps.java&& java BabySteps  


And then you can expect to see this output:

Crawling before walking, walking before jogging, jogging before running!


See if you can do the same and produce the same results.

Assuming that you will, Congrats!!!

That's a Great baby step, actually.

Natural questions should follow, like:

  • why did the file have to be named BabySteps.java?
  • what would happen if I named the file something else?
  • what would happen if my class wasn't named BabySteps?
  • what if I change the content of the System.out.println?
  • what is the purpose of the public static void main function?
  • what value does the args parameter to the main function provide?
These, and more are great questions and perhaps one of them is a good next baby step for you.

Some of them we'll get to in other posts.

Our goal is to keep it small each post, one baby step at a time.

Copyright © 2024 correlateencourage - All Rights Reserved.

.......................................



Comments

Popular posts from this blog

How to create a java app that converts fahrenheit to celsius and allows you to list the cities you want converted in an input text file

How to create a java app that creates a very simple plot from data in a csv file

Learn Java: The ABC's of Java