Day 3 Of Javatober And Learning What The JVM Is

in #java6 years ago (edited)

Day 3 And We're Getting Our Hands Dirty In My Month of Java

ai-close-up-code-160107.jpg
Image courtesy of pexel.com

I think it’s difficult sometimes to make sure you’re still learning when you’re trying to post daily. At this early stage, I need to make sure I’m not going overboard with my posts as firstly, I still need to be learning, but I think the most important thing is by posting, I am reinforcing what I am learning. So let’s not get hung up on introductions and lets get down to what I learned for the day.

What Did I Learn Today

  • How the JVM Works: It executes bytecode that’s been compiled. The JVM class loader takes the .class file created by the javac compiler and saves the bytecode in the JVM memory in the method area. The method area holds the class level information for each .class file. The head is part of the JVM memory is where the objects are allocated and JVM will create a class object for each .class file.
    The stack is also part of the JVM memory and is used for storing temporary variables. The PC registers keep track of which instructions have been executed and which one still needs to be executed. Each thread has a separate PC register where the Native method interface enables code to call or be called by native applications.
    Garbage collection is performed on each class that has been run, by automatically destroying it after use for memory management.
  • Our FirstJavaProgram line by line. The following is a breakdown of our first java program from yesterday.

Breaking down the program


Line 1 is the class definition and every java application must have at least one class definition. It is public and every program must have only one public class the same as the file name.

  1 public class FirstJavaProgram {

Line 2 is a public method, which means you can call it from outside the class. Static means it can be run without Java needing to create an object. Void doesn't mean anything. Main is the method name and will be the main entry point method from which JVM can run your program. (String[] args) is used for command line arguments, but is not used for this application.

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

Line 3 prints the contents inside the double quotes.

  3                 System.out.println("This is my first program in java");

Key Links


https://beginnersbook.com/java-tutorial-for-beginners-with-examples/

Code For The Day


Yep, this is the same as yesterday’s code, but wanted to go through everything line by line:

  1 public class FirstJavaProgram {
  2         public static void main(String[] args) {
  3                 System.out.println("Hello From Java World");
  4         }
  5 }

I'll be posting daily, sharing my experiences on my “1 Month of Java Code” experiences”, my previous post on day 2 can be found below, so feel free to have a look:
https://steemit.com/java/@run.vince.run/day-2-of-my-one-month-of-java-code

If you have found this post useful or interesting, please consider Commenting, Upvoting, Following and/or Resteeming

Sort:  

Congratulations! This post has been upvoted from the communal account, @minnowsupport, by run.vince.run from the Minnow Support Project. It's a witness project run by aggroed, ausbitbank, teamsteem, someguy123, neoxian, followbtcnews, and netuoso. The goal is to help Steemit grow by supporting Minnows. Please find us at the Peace, Abundance, and Liberty Network (PALnet) Discord Channel. It's a completely public and open space to all members of the Steemit community who voluntarily choose to be there.

If you would like to delegate to the Minnow Support Project you can do so by clicking on the following links: 50SP, 100SP, 250SP, 500SP, 1000SP, 5000SP.
Be sure to leave at least 50SP undelegated on your account.

Coin Marketplace

STEEM 0.17
TRX 0.15
JST 0.027
BTC 60654.57
ETH 2343.25
USDT 1.00
SBD 2.48