//改代码旨在分清实列方法和类方法的区别,用法
public class B{
int m; //定义变量m,成员变量可以初始不赋值,默认为0
static int n; //类变量
int max(int x,int y) //实列方法,后面不可以加符号
{
return x>y?x:y; //输送较大的一个数
}
void jerry() //实列方法 无参数
{
m=12;
n=90;
int r = max(m,n); //调用方法max
speak("hello"+r);
}
static void speak(String s) //类方法
{
n=100;
System.out.println(s);
outPut(n);
}
static void outPut(int x){ //类方法
System.out.println(x);
}
}
//该程序无法运行,因为没有主方法,
程序会出现无法运行情况,因在该代码中没有main函数,即程序无法找到入口