为什么我看到的类的方法有很多种
   到底是怎么分配的   
    大家说说撒
   鄙人是刚学的菜鸟 !
                别说的太深奥
  
                   谢过

解决方案 »

  1.   

    public class 汽车{   public void 启动(){....}
       public void 跑起来(方向){方向参数是传进来的}
       public void 停止(){....}
       public 油量 查看油量(){}
    }上面就是一个类,
    使用它:
    public static void main(String[],arg0){
       汽车 奥拓=new 汽车();
       奥拓.启动();
       奥拓.跑起来(朝前);
       System.out.print(奥拓.油量);
       奥拓.停止();
    }  
    我想楼主应该很清楚类的使用了吧,
      

  2.   

    建议您先看看JAVA 基础方面的书,要靠自己去理解,不懂了再问,这样进步的快!
      

  3.   

    那么类的方法
    比如说有的类是
    public String toString(){
    }
    有的是
    public void shout(){
    }  到底这些是依据什么情况而定义的呢
      

  4.   

    方法的命名么个人喜好吧
    建议lz系统的看一遍java基础吧
      

  5.   

    恩,系统学习一下java语法基础。
      

  6.   

    这样吖
       大家都是在怎么学习的呢!
            大家认为C++真的很难么 
              是不是学会了C++之后 再学JAVA 等其他语言都会变得相当容易
      甚至做到拿来就用的程度
      

  7.   

    个人认为
        只要学过C语言,其它的语言都好学,
            至于学会了C++之后再学习Java是一种错误的理解,
                C++的知识我现在一点不落的全部还给了老师,但它并为影响我学习java
                  还有就是给楼主一个建议
                        学习知识最主要的是心静,不要找捷径,一步一个脚印的走
                            先去看看java基础知识吧!
                                 希望我的建议对你有帮助!
      

  8.   


    谢谢 
            你们做飞行棋的时候是怎么做的呢
     现在我就差最后一步了的
          就是  
       我们老师他做了一个飞行棋 然后里面就是 角色A 和 B 在进行游戏  比如图是   AB============================
         比如A投掷点数为 5 就变到 B=====A=============    谁能告诉我这种方法的思路
      

  9.   

    不知道,从来没做过飞行棋,也不知道飞行棋是啥!你说的那些是命名规范,参考 Java Coding Style Guide,3.4 节,第 5 页:3.4  Method naming
    3.4  方法命名Method names* should use the infixCaps style. Start with a lower-case letter, and capitalize the first letter of any subsequent word in the name, as well as any letters that are part of an acronym. All other characters in the name are lower-case. Do not use underscores to separate words. Note that this is identical to the naming convention for non-constant fields; however, it should always be easy to distinguish the two from context. Method names should be imperative verbs or verb phrases. Examples:
    方法名应使用 infixCaps 格式。方法名以小写字母开头,后面的单词首字母,以及缩略词中的每个字母均采用大写形式,其他的字母均采用小写形式。单词之间不使用下划线进行分隔,需要注意的是这种命名约定与非常量字段的命名相同,但是这很容易在不同的情况下区分出来,方法名应该是个命令动词,或者是一个动词短语,例如:    // GOOD method names:  好的方法名:
        showStatus(), drawCircle(), addLayoutComponent()
        // BAD method names:   差的方法名:
        mouseButton() // noun phrase; doesn’t describe function  名词短语,无法描述功
        DrawCircle() // starts with upper-case letter  以大写字母开头了
        add_layout_component() // underscores   带有下划线
        // The function of this method is unclear. Does it start the
        // server running (better: startServer()), or test whether or not
        // it is running (better: isServerRunning())?
        // 这个方法的功能不是很清晰,这是开始运行服务器(startServer() 更适合)呢,
        // 还是测试服务器正在运行中(isServerRunning() 更适合)?

        serverRunning() // verb phrase, but not imperative   动词短语,但不是命令式的A method to get or set some property of the class should be called getProperty() or setProperty()
    respectively, where Property is the name of the property. Examples:
    用于获得(get)或者设置(set)类中一些属性的方法,应该分别写成 getProperty() 或者 setProperty(),其中的 Property 是属性名,例如:    getHeight(), setHeight()A method to test some boolean property of the class should be called isProperty(), where Property
    is the name of the property. Examples:
    用于检查类中一些布尔类型属性的方法,应该写成 isProperty(),其中的 Property 是属性名,例如:    isResizable(), isVisible()-----------------------------
      *  In Java, constructors are not considered methods; constructors of course always have the same name as the class. 在 Java 中,构造方法不能被当成是方法,构造方法名与类的名字一样。
      

  10.   


    哈哈,火龙果前辈啊,我帮你补补游戏的课,你教教我java 吧。。嘿嘿