方法定义和调用
package www.nihao;
public class demo03 {
public static void main(String[] args) {
int max=max(10,10);
System.out.println(max);
}
//求最大数的方法
public static int max(int x,int y)
{
int answer;
if(x==y)
{
System.out.println("number1=number2");
return 0;//有终止方法的作用
}
else if(x>y)
{
answer=x;
}
else
{
answer=y;
}
return answer;
}
}

浙公网安备 33010602011771号