Learning Programming #2.1 Learning Java: The Compiler

Like in most programming languages there is a compiler that translates your codes into something that can be executed by your computer. In some cases the compiler also optimizes your program and checks if your program could work.

In my last post you learned about the java syntax.

Every time you want to use a program you need to compile it before you can execute it. The compilation process is usually done by an IDE(Integrated Development Environment) like eclipse or using a command in the terminal/cmd.exe, but I wouldn't recommend this for beginners, especially when using windows.

The compiler is also a useful tool because it finds obvious errors(like syntax errors), that would lead to undefined behaviour during runtime.
Reading the compiler errors can be hard for beginners, but it usually follows a simple structure:

FileName:line: error: error-description
A copy of the code in the line the error ocurred
An arrow(^) pointing to the exact position the error ocurred.

The line can sometimes be misleading. For example when you forget a closing bracket, the compiler detects the error at the end of your program or when the compiler finds a structure that cannot be inside a certain "layer" of brackets(For example you normally can't put a function inside "()" like: (… void function(…) {…} …)).

Sometimes when you forget a "}" there can be over 100 errors. Because of that it might be useful to start at the beginning of the list of errors, since you don't need to wonder about the 99+ other errors that also had the same cause.

The error description in java is sometimes good and helpful when it points to the right point, as you can see in the following examples, but sometimes you might need to search the internet for help.
Screenshot from 2019-05-21 20-15-44.png
There are also 29 other errors below this section, that are caused by the last error(I replaced , with ; there).
As you can see it is always the best thing to start at the top of the list.

Some advanced IDEs are able to show the errors directly in the code and suggest a way of fixing it, making error fixing a very easy task.

Task

Write a program and fix all compiler errors.

An important thing that some programmers often forget:
The compiler is your friend, not your enemy.
It shows you really good where to find your errors.

Sort:  

Congratulations @quantumdeveloper! You have completed the following achievement on the Steem blockchain and have been rewarded with new badge(s) :

You published more than 10 posts. Your next target is to reach 20 posts.

You can view your badges on your Steem Board and compare to others on the Steem Ranking
If you no longer want to receive notifications, reply to this comment with the word STOP

To support your work, I also upvoted your post!

Vote for @Steemitboard as a witness to get one more award and increased upvotes!

@quantumdeveloper, thank you for supporting @steemitboard as a witness.

Here is a small present to show our gratitude
Click on the badge to view your Board of Honor.

Once again, thanks for your support!

Coin Marketplace

STEEM 0.28
TRX 0.11
JST 0.034
BTC 66272.75
ETH 3183.00
USDT 1.00
SBD 4.09