This commit is contained in:
@@ -143,3 +143,49 @@ The advanced way of implementing the garbage collection is *traversing the graph
|
||||
|
||||
You can go and learn about it [here](https://google.github.io/styleguide/javaguide.html).
|
||||
|
||||
# Hello World!
|
||||
|
||||
Let's create a file and name it `Helloworld.java`. I will annotate each code listing with a top comment with a filename for general understanding where the file is located and how it's called. And let's create a class.
|
||||
|
||||
```java
|
||||
// Helloworld.java
|
||||
|
||||
public class Helloworld {
|
||||
|
||||
}
|
||||
```
|
||||
|
||||
> [!NOTE]
|
||||
> Notice, that the name of the class should be the same as the name of the file it which it is created.
|
||||
|
||||
Let's define a method called `main` inside this class
|
||||
|
||||
```java
|
||||
// Helloworld.java
|
||||
|
||||
public class Helloworld {
|
||||
public static void main(String[] args) {
|
||||
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
This method will take an ***array of Strings*** called `args` as it's argument.
|
||||
|
||||
> [!NOTE]
|
||||
> The name `args` is just a common name. You can call it whatever you want. For example `params`.
|
||||
|
||||
This method is being called at the start of our program.
|
||||
|
||||
Let's try to *print* `Hello, world` to the console.
|
||||
|
||||
```
|
||||
// Helloworld.java
|
||||
|
||||
public class Helloworld {
|
||||
public static void main(String[] args) {
|
||||
System.out.println("Hello, world");
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
|
||||
Reference in New Issue
Block a user