我个人认为学习编程语言的基础是从demo中学习。
练习控制台输出东西,System.out.println输出换行,System.out.print输出不换行。
package com;
public class Test {
public static void main(String[] args) {
System.out.println(“hello,唐慧敏。”);
System.out.println(args[0]);
System.out.println(args[1]);
}
}
配置参数args:
运行结果:
package com;
public class Test {
public static void main(String[] args) {
System.out.print(“hello,唐慧敏。”);
System.out.print(args[0]);
System.out.print(args[1]);
}
}
运行结果:
输出由“*”组成的三角形
package com;
public class Test {
public static void main(String[] args) {
System.out.println(” *”);
System.out.println(” ***”);
System.out.println(” *****”);
System.out.println(“*******”);
}
}
运行结果:
输出符号表情
package com;
public class Test {
public static void main(String[] args) {
System.out.println(” ╭︿︿︿╮ “);
System.out.println(” {/ o o /}”);
System.out.println(” ( (oo) )”);
System.out.println(” ︶ ︶︶”);
}
}
结果:
原创文章,作者:Maggie-Hunter,如若转载,请注明出处:https://blog.ytso.com/18066.html