public static void 全局的静态的无返回值的方法,该方法属于类而不属于对象
如
class a
{
public static void fun()
{
System.out.println("hello");
}
////////////
void fun2()
{
System.out.println("world");
}
}
///////////////////
public class app
{
public static void main(String args[])
{
a.fun();//直接用类
a obj=new a();
obj.fun2();//用对象
}
}
如
class a
{
public static void fun()
{
System.out.println("hello");
}
////////////
void fun2()
{
System.out.println("world");
}
}
///////////////////
public class app
{
public static void main(String args[])
{
a.fun();//直接用类
a obj=new a();
obj.fun2();//用对象
}
}
解决方案 »
免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货