在java中方法应该如何使用,如何去定义,请说的具体点

[复制链接]
查看11 | 回复2 | 2008-8-15 13:51:11 | 显示全部楼层 |阅读模式
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();//这里调
回复

使用道具 举报

千问 | 2008-8-15 13:51:11 | 显示全部楼层
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
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

主题

0

回帖

4882万

积分

论坛元老

Rank: 8Rank: 8

积分
48824836
热门排行