(day4)Write a pair of Poker--The Class

JAVA is an object-oriented language,all things can be objects(saved in a class)
The method can't exist dependently in JAVA,we can only define it in a class

The static method

  1. A static method
    The static method is attached to th e class itself,and it will be loaded first compared with instance method
public class Person(){
public ***static*** void test(){

   }
}

This is a special defination mode,because its existence is along with the establishment of this Class--Person.
So we can only ues Person to invoke it.

public class Myclass(){
  Person.test(){

}

The instance method(实例方法)

The object method is attached to the object,we must establish an object of this class,and use it to invoke the object method.

public class Person(){
  public void eat(){
  
  }
}
public class Myclass(){
  person.p1 = new Person();
  p1.eat();  
}
静态方法.png
最后编辑于
©著作权归作者所有,转载或内容合作请联系作者
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

推荐阅读更多精彩内容

  • The Great A.I. Awakening How Google used artificial intel...
    图羽阅读 1,234评论 0 3
  • ViewsBecause view objects are the main way your applicati...
    梁光飞阅读 642评论 0 0
  • 大家好,本作者寒假闲来无聊,开个耽美文,结局是be,打算在二十篇内完成,如果少于十篇请打死我 “嘟——嘟……对不起...
    无岸呐阅读 118评论 0 1
  • 词是宋代盛行的一种文学体裁,宋词是一种相对于古体诗的新体诗歌之一,标志宋代文学的最高成就。宋词句子有长有短,便于歌...
    海滨公园阅读 134评论 1 9
  • 什么都舍不得 未尝不是一种失去 一直都在坚持 未尝不是一种放弃 心的天南地北 未尝不是一道藩篱 放不下的执著 扛不...
    禅味微凉阅读 175评论 0 0