some fixes

This commit is contained in:
Ellpeck 2019-10-10 12:00:38 +02:00
parent 0163500530
commit 61b5707057

View file

@ -3,9 +3,9 @@ So you want to learn to code. In my opinion, a good language for beginners is Ja
So let's start! So let's start!
# Setting it up # Setting it up
To actually be able to compile[^2] any Java code, you first need to download the [Java Development Kit](https://jdk.java.net/), or JDK for short. If you're a Linux or Mac user, you can just follow [their installation tutorial](https://openjdk.java.net/install/), and if you're on Linux, you can follow [this tutorial from Stack Overflow](https://stackoverflow.com/a/52531093). To check if the installation worked, you can just type `java -version` into a command prompt (which you can open on Windows by just typing `cmd` into your search). To actually be able to compile[^2] any Java code, you first need to download the [Java Development Kit](https://jdk.java.net/), or JDK for short. If you're a Linux or Mac user, you can just follow [their installation tutorial](https://openjdk.java.net/install/), and if you're on Windows, you can follow [this tutorial from Stack Overflow](https://stackoverflow.com/a/52531093). To check if the installation worked, you can just type `java -version` into a command prompt (which you can open on Windows by just typing `cmd` into your search).
Some people might disagree with me on this, but I recommend using an Integrated Development Environment (IDE) for development. An IDE is a program that helps you with coding by suggesting changes, notifying you of errors in your code and also allows you to easily run and debug your application. My personal suggestion would be to install [IntelliJ IDEA](https://www.jetbrains.com/idea/), but you could also use other IDEs like [Eclipse](https://www.eclipse.org/downloads/). Some people might disagree with me on this, but I recommend using an Integrated Development Environment (IDE) for development *especially* when you're just starting out. An IDE is a program that helps you with coding by suggesting changes, notifying you of errors in your code and also allows you to easily run and debug your application. My personal suggestion would be to install [IntelliJ IDEA](https://www.jetbrains.com/idea/), but you could also use other IDEs like [Eclipse](https://www.eclipse.org/downloads/).
The next thing you'll have to do is create a new project inside your IDE. For IntelliJ, all you have to do is click `New Project`, select `Java`, click `Next` twice and then type your project's name. I'm going to go with `JavaTutorial` for mine. The next thing you'll have to do is create a new project inside your IDE. For IntelliJ, all you have to do is click `New Project`, select `Java`, click `Next` twice and then type your project's name. I'm going to go with `JavaTutorial` for mine.
@ -25,7 +25,7 @@ That's it! If you now run your program (for IntelliJ, there should be a small gr
A lot of the code you see above doesn't *really* matter to you right now. The important stuff is this: A lot of the code you see above doesn't *really* matter to you right now. The important stuff is this:
- Each instruction, each thing that the program should do, ends with a semicolon `;` and usually a new line, though that is optional. - Each instruction, each thing that the program should do, ends with a semicolon `;` and usually a new line, though that is optional.
- Anything instruction you write between the inner curly braces `{}` will be executed in order of how it's written. - Any instruction you write between the inner curly braces `{}` will be executed in order of how it's written.
- `System.out.println("<enter anything here>")` is an instruction that causes a line of text to be written to the console. - `System.out.println("<enter anything here>")` is an instruction that causes a line of text to be written to the console.
As a little exercise, you can make your program output another line of text: As a little exercise, you can make your program output another line of text:
@ -56,7 +56,7 @@ public class Main {
``` ```
As you can see from line 6 and 7, to declare a variable, you need to put the variable's type first (`String` meaning text, `int` meaning an integer; a number without a decimal point), followed by the variable's name, which you can choose yourself. As you can see from line 6 and 7, to declare a variable, you need to put the variable's type first (`String` meaning text, `int` meaning an integer; a number without a decimal point), followed by the variable's name, which you can choose yourself.
For now, these variables don't have a value assigned to them yet. That's done in like 9 and 10. To assign a value to a variable, you first put the variable's name, followed by an equals sign `=`, followed by your desired value. For numbers, you can simply put them down, but text has to be wrapped in parentheses `""` (which is also why the text in lines 3 and 4 is wrapped in parentheses). For now, these variables don't have a value assigned to them yet. That's done in line 9 and 10. To assign a value to a variable, you first put the variable's name, followed by an equals sign `=`, followed by your desired value. For numbers, you can simply put them down, but text has to be wrapped in quotes `""` (which is also why the text in lines 3 and 4 is wrapped in quotes).
To actually do something with the variables, let's have them be printed out to the console. *I've omitted the rest of the code here because it's getting quite long, but I'm just adding the following lines inside the inner braces `{}` below the already written code.* To actually do something with the variables, let's have them be printed out to the console. *I've omitted the rest of the code here because it's getting quite long, but I'm just adding the following lines inside the inner braces `{}` below the already written code.*
```java ```java