实例
1.无参数无返回值类型:
public class Demo {
public static void main(String[] args) {
fun();
}
public static void fun() {
System.out.println("你好世界");
}
2.没有参数有返回值类型(注意:return返回值的数据类型与定义方法的返回值类型有关):
public class Demo {
public static void main(String[] args) {
String fun01 = fun01();
System.out.println(fun01);
}
public static String fun01() {
return "你好世界";
}
3.有参数没有返回值类型:
public class Demo {
public static void main(String[] args) {
fun04("苹果"