Lesson 0

Intro, installation and setup

Lesson Outcomes

By the end of this lesson you should:

  • Know what you will aim to learn in the course
  • Have your machine ready to build and run Java code
Welcome to Java for Beginners!

This course is intended to be an introduction to programming that happens to be in Java.

Many of the concepts you learn here are in the vast majority of programming languages out there; each one being a different tool for different jobs!

By the end of this course I hope you will have an awareness or understanding of:

  • The fundamental concepts that programming languages feature
  • Some basic object-oriented programming concepts

...and the ability to:

  • Solve problems by "translating English into Java"
  • Write small, interactive, multi-file Java programs

You can find runnable Java files for all code examples in the course source code.

As you're going through the slides, I strongly recommend you run the examples and edit them.

Try anything out and don't be afraid of breaking things, it's just text files and we have undo!

How do programs run on your computer?

Computers understand a fundamental set of instructions.

These instructions are however very primitive and way too low-level for everyone to write programs in.

Programming languages sit on top of these primitive instructions and give us a more human-friendly set of tools.

The world now has more programming languages than it knows what to do with - built not only on top of machine code but also on each other.

Each has it's own specialty or opinions that makes it the best for certain jobs, for example:

  • C is a language written originally for building operating systems for computers. It exposes enough of the machine level to let clever people do magic, and dangerous people cause many more bugs.
  • R specializes in statistical computing
  • Python is a general-purpose language focusing on readability

These languages end up running on computers in one of two ways:

  • The program source code is compiled (aka translated) to machine-understandable code before it can be run.
    • e.g. C, C++, Java*
  • An interpreter runs the program that knows how to turn your source into machine-understandable code while it runs.
    • e.g. Python, Java*

Java actually does both!

Java source is compiled to Java Virtual Machine (JVM) bytecode, which the JVM installed on supported machines can then interpret!
What is Java?

Java is one of the most popular programming languages used today! It is:

  • Object-oriented - You have objects of certain types, that have properties and ways to interact with those properties.
  • Class-based - You define the blueprints for objects before you create them.

Java is designed to be runnable everywhere by use of the Java Virtual Machine (JVM).

The JVM is written to run on most machines, and Java is compiled (converted) to a language that runs on the JVM.

Write Once, Run Anywhere is one of the biggest advantages of Java.

Because Java is used everywhere, it's used for many things.

It is used across Expedia Group for most of the functionality of our websites.

It has also been used to write:

  • Simulations
  • Video games
  • Development tools (like the one we'll be using)
  • Android apps*
(*In a sense, they use the same language, but Android doesn't use the JVM)
Common pitfalls

As with learning most things, we all make the same mistakes and assumptions, here's a list of what I've noticed while teaching this course.

  • You can refer to the lesson material while doing exercises - it's not an exam, treat it like you're solving any problem.
  • Lines that don't end in a bracket of some sort must end with a semicolon - this is so Java knows the expression you're writing is done.
  • Java is case sensitive - you must match the case and be consistent with your naming, otherwise your program will break!
  • Every open bracket, brace, and parenthesis must have a matching close - this is how Java knows what context something is happening in. If they're in the wrong place you're likely going to run into problems.
  • If your program is in an unhappy state please ask for help! - It's much easier for us to fix something as soon as it goes wrong, rather than after you finish writing and it won't compile.
  • Coding is both a science and an art - There usually is more than one way of solving a problem. By all means consult with your fellow learners, but don't panic if their solutions are not the same as yours.
Setup

In this lesson we are going to get your machine ready for writing, compiling, and running Java programs.

Click here to go to the guide.