<!-Title: "Hello World" in Java->
For studying, I implemented "Hello World" in various languages.
Java.
Visual Studio Code (Windows version)
Windows Subsystem for Linux (Ubuntu 18.04 LTS)
javac 1.8.0_181 openjdk 10.0.2 2018-07-17
Hello World
HelloWorld.java
public class HelloWorld {
public HelloWorld(int count) {
this.count = count;
}
private int count;
private void sayOnce(Integer value) {
System.out.println("Hello, world. " + value.toString());
}
public void say() {
for (int i = 0; i < this.count; i++) {
sayOnce(i);
}
}
public static void main(String[] args) {
HelloWorld hw = new HelloWorld(10);
hw.say();
}
}
Hello, world. 0
Hello, world. 1
Hello, world. 2
Hello, world. 3
Hello, world. 4
Hello, world. 5
Hello, world. 6
Hello, world. 7
Hello, world. 8
Hello, world. 9
I finished it in a similar way to C ++.
I haven't touched Java itself so much, but I use C # a lot, so I could write it without any discomfort.
Recommended Posts