How to print out hello world in java

How to print out hello world in java



Taking the step to print "hello world" is one of the first steps recommended in most programming languages.

It's also one of the most common steps to take when experimenting with something new in a given language.

It's even a quick opportunity when you want to test out something complex in an isolated manner.

So let's do it, and discuss it, just a bit ...


Here's the code:

  1 public class HelloWorld {

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

  3         System.out.println("hello world");

  4     }

  5 }

Here's what we used when building this code:

* java 8

* vim editor (note: we have much love for intellij and other editors too!)

* code was placed in a file named HelloWorld.java

Here's what we did to run the code:

* javac HelloWorld.java

* java HelloWorld

Here's what you'll see when you run it:

hello world

Here's a bit of description about the code and concepts used:

  • the public class name of HelloWorld is the same as the filename, and that's important in order for the file class to compile
  • The syntax System.out.println is used for printing lines of content, and the content that you want to be printed belongs between the quotes
  • The typical public static void main function is added and is the entry point to the application

Another baby step completed, nice job!

Want to know how to do something in java or have any questions?  Let me know by commenting, and we'll consider getting there as we continue to take baby steps!

Copyright © 2024 correlateencourage - All Rights Reserved.

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

Practicing baby steps is one of the things we believe correlates with success, and keeping track of your practice experience is another.  It's one of the many things you can track with our correlateencourage app, available here at the apple store: https://apps.apple.com/us/app/correlateencourage/id6504427387  


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