Styudent-ID :045756G Author :宮城裕介 Date :2004/11/1
Report#1 1.課題 例題Helloを以下のように書き換えて、出力せよ。
プログラムの例(Hello.java) public class Hello { public static void main(String[] argv){ System.out.println("Hello, Java World!"); } } |
○(a)について public class repo1 { public static void main(String[] args) { System.out.println("MY NAME IS..."); } } ○実行結果 MY NAME IS... |
○(b)について public class repo1_b { public static void main(String[] args) { System.out.println("MY NAME IS..."); System.out.println("MY NAME IS..."); System.out.println("MY NAME IS..."); } } ○実行結果 MY NAME IS... MY NAME IS... MY NAME IS... |
○(c)について ublic class repo1_c { public static void main(String[] args) { System.out.println("Hello,"); System.out.println("Java World!"); } } ○実行結果 Hello, Java World! |
○(d)について public class repo1_d { public static void main(String[] args) { System.out.println("printlnの場合"); System.out.println("MY NAME IS..."); System.out.println("MY NAME IS..."); System.out.println("printの場合"); System.out.print("MY NAME IS..."); System.out.print("MY NAME IS..."); } } ○実行結果 printlnの場合 MY NAME IS... MY NAME IS... printの場合 MY NAME IS...MY NAME IS.. |
○(e)について public class repo1_e { public static void main(String[] args) { System.out.print("NAME "); System.out.print("NAME "); System.out.print("NAME "); } } ○実行結果 NAME NAME NAME |
○(f)について public class repo1_f { public static void main(String[] argv){ System.out.println(" * "); System.out.println(" *** "); System.out.println(" ***** "); System.out.println(" *** "); System.out.println(" * "); } } ○実行結果 * *** ***** *** * |
○(g)について public class repo_g { public static void main(String[] args) { System.out.println(" * "); System.out.println(" * * "); System.out.println(" * * "); System.out.println(" *******"); System.out.println(" ** "); System.out.println(" ** "); } } ○実行結果 * * * * * ******* ** ** |
public class クラス名 { public static void main(String args[]) { // 処理部分 // : // : } } |
public class Sample { public static void main(String args[]) { System.out.println("Sample"); } } |
public class Sample { public static void main(String args[]) { System.out.println("Sample") // ";"をはぶいてみた } } ------------これをコンパイルしてみると---------------------------- Sample.java:3: ';' がありません。 System.out.println("Sample") ^ エラー 1 個 |