//first Java program Welcome.java
public class Welcome
// Welcome is class,the first letter of the class's name should be capitalization
{
public static void main(String[] args)
{
String[] greeting = new String[3];
greeting[0] = "Welcome to Core Java";
greeting[1] = "by Cay Horstmann";
greeting[2] = "and Gary Cornell";
for (int i = 0; i < greeting.length; i++)
System.out.println(greeting[i]);
}
}
Execute
by Cay Horstmann
and Gary Cornell
Process completed.
博客展示了一个Java入门程序,定义了名为Welcome的类,在main方法中创建了一个字符串数组greeting并赋值,最后通过循环打印数组元素。此程序体现了Java类的定义、字符串数组使用等基础操作。
1898

被折叠的 条评论
为什么被折叠?



