We have summarized the advantages and disadvantages of Java, a wonderful language used for Android and games.
Object-oriented is what makes a program more readable. Intuitive programming is possible by calling the add method (a group of processes) to add to the list. You can do object-oriented programming in Java with classes.
Add an item to the list
list.add(item);
A type is the type of value of a variable (string, number, etc.). For example, suppose you have a program created assuming that the variable num contains a number. However, if you mistakenly pass a character string when using that program, an error will occur because it is not a numerical value at runtime. In Java, it cannot be executed if the type is different in the grammar check called compilation. It may be a hassle, but it is a merit to notice before execution.
Example using type
int num;//Numerical value(Integer)Can only be entered. Also, variables cannot be used unless they are declared.
num = "String";// "で囲むとStringを使える。また整数でないのでエラーを出す
int num2;
num2 = num + 1;//Can only be calculated as an integer
You can program without depending on the OS.
The description is long and a little difficult to read. In the case of learning, I think that you can easily learn by using jshell (Java tool). The following is a program that outputs Hello! To the screen. If you want to run jsell, you can start by typing `` `jshell``` in the terminal.
When writing to a file
public class Main {
public static void main(String[] args) {
System.out.println("Hello!");
}
}
For jshell
System.out.println("Hello, World");
For windows, to install Java you have to download it from the Oracle homepage, install it and add it to your environment variables. It's a lot of work for beginners. For Ubuntu, it is recommended because it can be completed with sudo apt install openjdk-jdk-11-headless
.
You'll understand the essence of object-oriented programming by learning it, not just Java, and you'll find it easy and fun to program. Try it even if you have already learned another language.
Recommended Posts