I have recently been accepted to a full-stack developer apprenticeship. Although I am excited about this awesome opportunity, I am equally as nervous because I will be undergoing some rigorous training with a completely different stack than I'm used to, starting with Java.
I am currently trying to get ahead of the curve by learning some Java fundamentals with Codecademy.
TIL
Today I learned about:
- Classes
- Print Statements
- Compilation
- Javadoc Comments
Classes
I understand classes to be abstracted pieces of code.
The part of classes that I need to be more comfortable with is writing the full defining syntax.
public class myClass {
public static void main(String[] args) {
}
}
I haven't looked into it yet but, I'm hoping that working on Java code with an IDE will auto write things like this.
Print Statments
I am used to using console.log in Javascript and print/puts in Ruby and also return to display data or information but Java uses System.out.println and System.out.print and each has a subtle difference.
- System.out.println() - will print to the console and then create a new line.
- System.out.print() - will print everything on the same line.
Compilation
The compiling process catches mistakes before the computer runs our code.
Java is a compiled programming language. Although, Codecademy has automatically compiled and run the files for me, I was also able to compile and execute some files myself.
To compile a file, first use the terminal command:
javac FileName.java
A successful compilation produces a .class file (FileName.class).
Afterwards, to execute it, use the terminal command:
java FileName
An unsuccessful compilation should produce a list of errors.
Comments
Apart from the usual suspects (single and multi-line comments) Java also has another comment called Javadoc comments.
A Javadoc comment is represented by using the (/)** and (*/) symbols.
They are used to create documentation for APIs. When writing Javadoc comments, its important to remember that htey will eventually be used in the documentation that your users might read so it's important to make sure to be especially thoughtful when writing these comments.
These comments are typically written before the declaration of fields, methods, and classes.
I am excited to continue learning more and will do my best to keep documenting my progress.
Top comments (0)