You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
Learn/Jb14_Function.java

22 lines
369 B

public class Jb14_Function
{
public static void main(String[] args)
{
/*函数格式:
修饰符 返回值类型 函数名(参数类型 形式参数1,参数类型 形式参数2,.......)
{
执行语句;
return返回值;
}
*/
//定义一个功能,求两数之和
int sum = add(6,2);
System.out.println(sum);
}
public static int add(int a,int b)
{
int sum = a+b;
return sum;
}
}