First , please understand its feature :

* no need to instantiate a instance, i.e. simply you can just write: AutoTrace.start();

* All instances will share one static method, consider the consistency when the method operate a static (global) variable. [ as to its local variables, each thread has self stack. This's similar to non-static method ]

Then to consider whether to declare as static :

* If you really no need to construct a java instance before call its method

* the static variable of the static method is immutable or not / no need to consider its consistency [ i.e. locking ]

....

When to use static method in a java class的更多相关文章

  1. java.lang.NoSuchMethodError: No static method setLayoutDirection(Landroid/graphics/drawable/Drawable;I)V in class Landroid/support/v4/graphics/drawable/DrawableCompat

    Bug: java.lang.NoSuchMethodError: No static method setLayoutDirection(Landroid/graphics/drawable/Dra ...

  2. java.lang.NoSuchMethodError: No static method getFont

    最近在Android Studio升级3.0后,在AlertDialog弹窗时报出了如下问题: java.lang.NoSuchMethodError: No static method getFon ...

  3. java方法句柄-----5.Method Handles in Java

    Method Handles in Java 目录 Method Handles in Java 1.介绍 2.什么是MethodHandle 3. Method Handles vs Reflect ...

  4. [ReadingNotes] Search the links, static final in the java

    [ReadingNotes] Search the links, static final in the java */--> pre { background-color: #2f4f4f;l ...

  5. Python Static Method

    How to define a static method in Python?Demo: #!/usr/bin/python2.7 #coding:utf-8 # FileName: test.py ...

  6. Python OOP(2)-static method,class method and instance method

    静态方法(Static Method): 一种简单函数,符合以下要求: 1.嵌套在类中. 2.没有self参数. 特点: 1.类调用.实例调用,静态方法都不会接受自动的self参数. 2.会记录所有实 ...

  7. Arrays.asList()后调用add,remove这些method时出现java.lang.UnsupportedOperationException异常

    String[] queryNames = request.getParameterValues("queryName"); List<String> queryNam ...

  8. How to call getClass() from a static method in Java?

    刚才在学习Java 使用properties类,遇到这样的错误: Cannot make a static reference to the non-static method getClass() ...

  9. 【转】 Java虚拟机内存的堆区(heap),栈区(stack)和静态区(static/method)

    JAVA的JVM的内存可分为3个区:堆(heap).栈(stack)和方法区(method) 堆区:1.存储的全部是对象,每个对象都包含一个与之对应的class的信息.(class的目的是得到操作指令 ...

随机推荐

  1. Linux用户密码期限修改

    今天有开发报故,sftp无法登录.检查服务都是正常的,之前3月份也出现过此问题,当时忙没有注意,现在看每3个月出现问题.这才想到是密码过期导致的. 先重置用户密码,发现过期日志为Oct 08, 201 ...

  2. 42.Trapping Rain Water---dp,stack,两指针

    题目链接:https://leetcode.com/problems/trapping-rain-water/description/ 题目大意:与84题做比较,在直方图中计算其蓄水能力.例子如下: ...

  3. 136.Single Number---异或、位运算

    题目链接 题目大意:给出一串数组,里面的数都是两个,只有一个数是一个,把这个只有一个的数找出来.时间复杂度最好是线性的,空间复杂度最好为O(1). 法一:利用map,空间换时间,代码如下(耗时26ms ...

  4. 85.Maximal Rectangle---dp

    题目链接:https://leetcode.com/problems/maximal-rectangle/description/ 题目大意:给出一个二维矩阵,计算最大的矩形面积(矩形由1组成).例子 ...

  5. B2旅游签证记

    先去https://ceac.state.gov/ceac/,选择DS-160表格,在线申请登记个人信息 ,选择大事馆“CHINA BEIJING”和验证码,点 Start an Applicatio ...

  6. u-boot启动第一阶段

    目标板:2440开发板 u-boot启动的第一阶段是在文件start.S中完成的,这个过程对不同硬件平台的设置是不同的.下面进入start.S _start: b reset //跳转到reset / ...

  7. scrapy shell 用法(慢慢更新...)

    scrapy shell 命令 1.scrapy shell url #url指你所需要爬的网址 2.有些网址数据的爬取需要user-agent,scrapy shell中可以直接添加头文件, 第①种 ...

  8. Codefroces 735D Taxes(哥德巴赫猜想)

    题目链接:http://codeforces.com/problemset/problem/735/D 题目大意:给一个n,n可以被分解成n1+n2+n3+....nk(1=<k<=n). ...

  9. jenkins+docker持续集成实验

    在互联网时代,对于每一家公司,软件开发和发布的重要性不言而喻,目前已经形成一套标准的流程,最重要的组成部分就是持续集成(CI)及持续部署.交付(CD).本文基于Jenkins+Docker+Git实现 ...

  10. hdu4796

    4月真是没写啥题,这题还是月初写的…… 不错的插头dp,首先由n和m的范围知肯定是轮廓线是横向划的 问题的难点在于怎么处理下面两个问题 1.怎么处理独立插头 2.怎么处理完全将W和L左右隔开 先说独立 ...