class A{public void method1(){ }public static void staticmethod1(){ }} 这样就定义了两个方法,java所有方法都是存在于类中如上,这两个方法存在于A类中。可以写另一个类来用这两个方法。class usemethod{ public static void main(Strubg args[]) {
A.staticmethod1();//这里调用了A类的静态方法staticmethod1.
A a = new A();
a.method1();//这里调
Fields and methods When you define a class (and all you do in Java is define classes, make objects of those classes, and send messages to those objects), you can put two types of