System.out.println(“Learning Java”);

Kelsey H.
2 min readDec 2, 2023

This week I finally took the first step in learning Java fundamentals and syntax. Codecademy’s Java course is a great entry-level course whether you have programming experience or are coming in completely new and fresh face. The lessons are unassuming, and by that I mean they don’t start by pushing you off from the deep end of the pool.

My initial impression of Java is that it holds a lot of similarities with JavaScript and TypeScript. This makes sense because as an object-oriented programming language, concepts such as inheritance, classes, polymorphism, abstraction, methods, etc. are crossed over. I appreciated having an understanding of these and other concepts going into the lessons.

As with every new language, I was introduced to how to print Hello World into the console.

System.out.println(“Hello World!”); 

System is a built-in Java class. Referencing it gives you access to various methods built into it. The above statement tells the console, “Hey! I want to print this String, “Hello World!”, back to the console.” It’s the Java equivalent to JavaScript’s console.log() method.

There are 2 ways you can return a value to the console using print. By using, println() the computer will print the input out onto a new line.

System.out.println("I'll be on one line!"); 
System.out.println("I/'ll be on another line!"); //prints on a new line

Alternatively, you can simply use print() which will print the values onto the same line.

System.out.print("Here I am! "); 
System.out.print("I am here too!");

//prints Here I am! I am here too! on one line

You don’t only have to return Strings. You can also perform comparisons, calculations, or return a variable and have the console display the value it stored.

System.out.println(3); //prints 3 
System.out.println(4 > 5); //prints false;

double price = 3.05
System.out.println(price); //prints 3.05

Similar to console.log(), println() can be used to check if your code is doing what is intended and expected. The compiler is great at catching syntax bugs (I could honestly wax poetic about how much I actually really like the ability to compile and debug before actually running my code).

This method comes in handy if I want to check a value of a variable that is returning an incorrect answer before sending it to be displayed on the client-side (if I’m building the back-end for a web application).

Now that we’ve got a small look at printing to the console, next up will be data types and variable declarations.

Thank you for reading!

Sign up to discover human stories that deepen your understanding of the world.

Free

Distraction-free reading. No ads.

Organize your knowledge with lists and highlights.

Tell your story. Find your audience.

Membership

Read member-only stories

Support writers you read most

Earn money for your writing

Listen to audio narrations

Read offline with the Medium app

Kelsey H.
Kelsey H.

Written by Kelsey H.

My three favorite things are coding, gaming, and caffeine.

No responses yet

Write a response