Member-only story

From Python To Java (Part 1)— The Basics

Liu Zuo Lin
4 min readDec 11, 2021

--

This series of articles is written for those of you who are somewhat comfortable in Python, and are looking to pick up some Java. In this article, we’ll do a couple of basic tasks in Python, and then the equivalent in Java

1) Printing Hello World

hello.py

print("hello world")

Note that we can call our file whatever we want eg. helloworld.py, hi.py, aaaaa.py and it wouldn’t matter.

Hello.java

Note that:

  1. The file name Hello.java must be the same as our class name Hello
  2. There must be a main function
  3. print in Python → System.out.println in Java
  4. The other weird stuff that you see will explained later

2) Running Our Code (using CMD/Terminal)

Running hello.py

python hello.py

--

--

Liu Zuo Lin
Liu Zuo Lin

Written by Liu Zuo Lin

SWE @ Meta | [Ebook] 101 Things I Never Knew About Python: https://payhip.com/b/vywcf

Responses (1)