At this point the following should work. If you're done, install a Java Linter on your editor of choice.
java -version
javac -help
An object-oriented programming language. It is compiled to bytecode which can then run on any Java Virtual Machine (JVM).
- Statically typed, which ensures functions return a certain type of result. This catches bugs early on in the process.
- Compiled to bytecode which can then be run on any JVM regardless of computer architecture.
- It's super popular and can gain you entry to lots of companies.
- Owned by Oracle.
- Very verbose compared to other languages.
- Requires compilation which can be kind of slow.
Write a basic HelloWorld class. Output some text to the screen.
- What is
void
doing? - What do you expect to happen if we change
void
to a different type? - What is required to run a simple Java program?
- A main method
- Compile with
javac
- Run with
java
Let's make a simple Aloof class that makes something we say more aloof. For example:
I love rain >> I love rain, I guess...
- Create a new class called Aloof.
- Create a main function.
- Let's talk about "args" -- we will go over this soon but it's an array of strings. It will take arguments we pass in and put them into an array.
- Access the first item in the array and print it out along with ", I guess..."
- What is args?
- An array of arguments passed in after running the java file.
- How can you access values in arrays in Java?
- With bracket notation!
Go through the syntax section up until Arrays (we'll cover that after lunch). We'll come back together at 11:15am to go over some of what we learned.
- What is the difference between an instance and class method?
- Class methods can be called internally (and off the class).
- Instance methods require an instance to be created first.