# Java練習問題 ## 定着度確認 では、ここまでやった知識を基に問題を解いてみよう ### 問題 #### 1. Hello World 出力に`Hello World`が出るようにしよう <details><summary>ヒント</summary> 出力の関数は System.out.println() </details> #### 2. 変数の使い方 変数`x`に、1を代入して出力してみよう <details><summary>ヒント</summary> Javaにおける定義はC++のように,int 等を書く必要があります。 </details> #### 3. 変数の使い方2 変数`x`に`"hoge"`を代入して出力しよう <details><summary>ヒント</summary> 問題2参照 </details> ### 解答 #### 1. Hello World コード ```java= public class Main { public static void main(String[] args){ System.out.println("Hello World"); } } ``` 実行結果 ``` Hello World ``` #### 2. 変数の使い方 コード ```java= public class Main { public static void main(String[] args){ int x = 1; System.out.println(x); } } ``` 実行結果 ``` 1 ``` #### 3. 変数の使い方2 コード ```java= public class Main { public static void main(String[] args){ String x = "hoge"; System.out.println(x); } } ``` 実行結果 ``` hoge ```