Because everyone likes ramen. Learn the basics of Java through ramen.
--Become able to understand and write the basics of Java
I hope readers have reached this level.
In programming learning, the introduction that corresponds to "This is a pen." Is to output "Hello World!". However, everyone who loves ramen will be asked to output "I love ramen".
The keyword when you want to output in Java is System.out.println(); is. The contents put in this () are output.
If you want to output "I love ramen", do this.
Main.java
public class Main {
public static void main(String[] args) {
System.out.println("I love ramen");
}
}
now, public class Main public static void main(String[] args) I don't care about that ** System.out.println (); ** "I love ramen" in () Make sure that is included.
If you execute it in this state, it will be displayed on the console. I think that "I love ramen" will be output.
Just in case, please be careful
-"", (), {} must be half-width.
is. If you keep this, it should work.
Now, what if you want to eat ramen? It's okay if you replace "I love ramen" with "I want to eat ramen".
Main.java
public class Main {
public static void main(String[] args) {
System.out.println("I want to eat ramen");
}
}
I think you can tell that you want to eat ramen.
Let's write the "I love ramen" sentence written above a little smarter. Use variables to write smartly.
Variables are often likened to boxes. By putting letters and numbers in a box, people who see the box can check and use the values in it.
However, since it is "Java learned from ramen", I will explain about ramen.
When we eat ramen at the store, the ramen is in a bowl. There should be no store that hands you noodles and soup. Please think here that the "variable" corresponds to this "vessel".
The ramen made by the shopkeeper is put in a bowl and provided to us, and we receive the ramen inside the bowl.
The same is true for Java (and many programming languages), where someone puts the result of a calculation into a "variable" and we use the contents of that variable to do more calculations or output the contents.
Now, let's write a "I love ramen" sentence using variables.
Main.java
public class Main {
public static void main(String[] args) {
String love = "I love ramen";
System.out.println(love);
}
}
Here, I put your ramen love in a variable called "love". System.out.println(love); Is outputting the contents of your love.
"Wait a minute, what is" String "?" Please wait for the next time.
Recommended Posts