java 静态方法static 与 动态方法的使用对比

来源:互联网 发布:asp学生管理系统源码 编辑:程序博客网 时间:2024/06/02 04:18

例如:

import java.util.Objects;/** * * @author cmx */public class static_function {    public static void main(String[] args)    {        //静态方法举例(API中以static开头的方法为静态方法):  java.util.Objects包中的 static int hashCode(Object a)        System.out.println(Objects.hashCode("hello"));        //非静态方法举例(API中没有以static开头的方法为非静态方法): java.lang.Object包中的public int hashCode()        System.out.println("hello".hashCode());         /**     * 总结:静态方法static ,需要 :类名.方法名(参数);     * 非静态方法:需要:对象名.方法名();   括号内为空;     * 比如Employee中的getName     */    }}
阅读全文
0 0
原创粉丝点击