Skip to main content
·2 min read

A Few Java Factoids - Part 1

Java basics: Learn to code with simple examples—comments, main methods, and syntax essentials. Get comfy with semicolons and curly braces!

A Few Java Factoids - Part 1

A few basic facts about Java

I’m taking a Java class right now, and sometimes just looking at code is really great to get the learning started. Meant for beginners, I’ve come up with a few basic code samples to showcase as a convenient way of getting to know Java. You and me are going to explore the bare surface of the digital hieroglyphics of Java and its all wonderful ciphers! :D

Let’s look at comments first:

Single line comments

// stuff

Multi-line comments

/* more stuff */

Okay, so that was super easy…Go ahead, press the button! :D Virtually…

So moving on…to the main method!

This is the main method that you’re going to use every time you run a Java program, unless you’re making just a class file, in which case you will not need the whole public static void main (String[] args), but you will still need [class] with the class name next to it.

Brackets or the curly braces \{ \} are required at the beginning and end of each method you’ve used to indicate when you’ve finished the programming statements for that particular method.

Finally, for each System.out.println("Text"); that you have there always needs to be a ; at the end. Always! So get used to it!

If you decide NOT to put the stupid ; at the end of your output statements, you WILL get an ERROR.

Also, in case you were wondering, with most IDEs or Integrated Development Environments, there is syntax highlighting which makes it easier to understand what’s going on by adding color to the types of different texts.

For example, with the Strings involved in the program, they are the color [red]. With the comments involved in the program, they are the color [gray]. Different methods are highlighted in [blue].

So that’s pretty much it for the super duper basics of any Java program.

Remember, you gotta have your:

  • main method public static void main (String[] args)
  • curly braces \{ \}
  • semi-colons ;
  • comments to explain what the heck you’re doing in the program such as //single-line stuff or /*multi-line stuff*/

Get it? Got it? Good.


Tags 🏷️

Stay in the loop

🦄 The Unicorn Engineer ✨

Personal and career learnings, advice, collaboration opportunities, and more. Delivered straight to your inbox.

No spam. Unsubscribe anytime.

Keep Reading

Related Posts

Java Bits - Getting Started
·8 min read

Java Bits - Getting Started

The first bit in a mini-series for beginners in Java. Welcome, welcome Moving from Python, we’ll be looking at Java - AWW YEANow Java is by far one of the most

Blog
Python Bits - Getting Started
·7 min read

Python Bits - Getting Started

The first bit in a mini-series for beginners of Python. Hello, hello, hello Welcome to Python Bits, where you’re introduced to increasingly difficult program pr

Blog
Integrating Your School Emails With Airmail
·4 min read

Integrating Your School Emails With Airmail

So in case you haven't heard of it yet, Don't Starve is this awesome Indie game. So I have 4 different email accounts, my personal one, and then 3 other ones fo

Blog

Stay in the Loop ✍🏽

I share thoughts on engineering, career growth, and the tech industry. Follow along for more.