Embarking On The Journey To Apex Heroism (Or Unraveling The Secrets Of A Java Class)


So far, Head First Java has proven to be an easily digestible read. Its teaching method is engaging, featuring abundant visuals and a conversational style. The inclusion of puzzles, such as crosswords, fill in the blanks, and match-ups, aligns well with my preferred learning style. Despite my goal being to learn Apex, I find myself immersed in a book about Java. The rationale behind this choice is that Apex is derived from Java, and the syntax between the two languages is apparently quite similar. Hence, this book seems to be an excellent resource for gaining a foundational understanding of Java.

Since I find that writing things down aids in retention, allow me to share my recent learnings.

Java code can be written in any text editor—I’m leaning towards Sublime Text, but any editor will suffice. The code is organized into source files, each containing a single class. Classes, in turn, consist of methods, which house statements responsible for executing actions. To illustrate, if I were to create a class for a dog, there might be various methods like bark(), walk(), and eat(). Each of these methods would contain the code essential for their respective functionalities.

In summary, the fundamental structure of a class follows this outline:

public class MyFirstApp 
     { public static void main (String[] args) 
         {
          system.out.print("Java is cool, ");
          system.out.print("and so is Apex!");
          }
     }

Let’s break down the code step by step:

  • “public” signifies that anyone can access this class.
  • “class” indicates that we are defining a class.
  • “MyFirstApp” is the name assigned to the class.
  • Everything enclosed within the orange curly braces constitutes the class contents. In this case, there is a single method, and its content is enclosed within the blue curly braces.
  • “public” signifies that anyone can access this class.
  • “static” (currently unclear, but I’ll provide an explanation when I discover more).
  • “void” indicates that this method does not return anything.
  • “main” is the name of the method and serves as the starting point for the class. Every class requires one main method, as it is the initial method executed in the class, essentially the “start here” point.
  • “(String[] args)” signifies that methods can receive information or “arguments.” In this instance, an array (a group of data) of strings is being provided.
  • “System.out.print” indicates that the method contains statements, specifying that we want to print something—in this case, “Java is cool, and so is Apex!” (without the quotes).
  • “;” signifies the end of a statement.

While there is more to learn, this should suffice for now, with more insights to follow.

I’m thrilled that I comprehend the material I’ve been reading. It’s remarkable because just two weeks ago, I had no understanding of what I was observing. This is promising news, as I’ve encountered elements I don’t yet grasp, but I am confident that with continued effort, I will eventually comprehend them. That’s my story, and I’m committed to it!