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. 85.Maximal Rectangle---dp

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

  2. initialization 与 finalization 执行顺序 研究

    看GIF: 第二个GIF: DEMO下载:http://files.cnblogs.com/files/del88/InitOrderDemo.zip

  3. golang之终端操作,文件操作

    终端操作 操作终端相关的文件句柄常量os.Stdin:标准输入os.Stdout:标准输出os.Stderr:标准错误输出 关于终端操作的代码例子: package main import " ...

  4. C# 中DateTime的各种使用

    获得当前系统时间: DateTime dt = DateTime.Now; Environment.TickCount可以得到“系统启动到现在”的毫秒值 DateTime now = DateTime ...

  5. CSU 1356 Catch

    原题链接:http://acm.csu.edu.cn/OnlineJudge/problem.php?id=1356 题目需要我们判断给定图在某一步是否会有可能出现在所有节点.首先,我们不妨假设给定图 ...

  6. Eclipse如何定位到某一个类所在硬盘上的位置

    解决方法:安装OpenExplorer_1.5.0.v201108051513.jar插件 将OpenExplorer_1.5.0.v201108051513.jar文件添加到Eclipse所在目录下 ...

  7. 常用的scrapy setting

    原文请参考    Scrapy 爬虫入门教程十三 Settings(设置), 讲的很详细 官网参考  Settings 设置 Scrapy 设置允许您自定义所有 Scrapy 组件的行为,包括核心,扩 ...

  8. linux中忘记root密码解决方案

    方法一: 如果用户具有sudo权限,那么直接可以运行如下命令: #sudo su root #passwd #更改密码 或者直接运行sudo passwd root命令就可以直接更改root密码. 有 ...

  9. Python并发编-用Event,线程检测数据库连接的例子

    尝试3次连接数据库 import time import random from threading import Thread,Event def connect_db(e): count = 0 ...

  10. MPI - 缓冲区和非阻塞通信

    转载自: Introduction to MPI - Part II (Youtube) Buffering  Suppose we have ) MPI_Send(sendbuf,...,,...) ...