`
william_ai
  • 浏览: 20675 次
  • 性别: Icon_minigender_1
  • 来自: 杭州
社区版块
存档分类
最新评论

a==null vs null==a

阅读更多
public class A{
        void a(){
                String a = null;
                if(a==null){}
        }
        void b(){
                String a = null;
                if(null==a){}
        }
}

void a();
  Code:
   Stack=1, Locals=2, Args_size=1
   0:   aconst_null
   1:   astore_1
   2:   aload_1
   3:   ifnonnull       6
   6:   return
  LineNumberTable: 
   line 3: 0
   line 4: 2
   line 5: 6

  StackMapTable: number_of_entries = 1
   frame_type = 252 /* append */
     offset_delta = 6
     locals = [ class java/lang/String ]


void b();
  Code:
   Stack=2, Locals=2, Args_size=1
   0:   aconst_null
   1:   astore_1
   2:   aconst_null
   3:   aload_1
   4:   if_acmpne       7
   7:   return
  LineNumberTable: 
   line 7: 0
   line 8: 2
   line 9: 7

  StackMapTable: number_of_entries = 1
   frame_type = 252 /* append */
     offset_delta = 7
     locals = [ class java/lang/String ]


}

今天看到一段代码,类似b方法的调用,于是就开始掉过来哪个快点。从BC上看a方法要快一点。具体的性能测试还有待验证。
分享到:
评论

相关推荐

    undefined==null引发的两者区别与联系第1/3页

    (不过要注意如果你的x==0也是合法值的话就不能使用if(x){}来做条件判断了) 为了证明这种多余,俺也特意做了以下测试: var a; alert(x) if(x==null){ alert(‘failed’) } 其中x为一个未初始化

    Java工具类

    public static boolean isNull(Object a) { String b = toString(a); return isNull(b); } public static boolean isNull(String a) { a = ("" + a).trim(); if (a == null || "".equals(a) || "null".equals...

    mysql 断电不能启动

    InnoDB: Failing assertion: addr.page == FIL_NULL || addr.boffset >= FIL_PAGE_DATA InnoDB: We intentionally generate a memory trap. InnoDB: Submit a detailed bug report to http://bugs.mysql.com. InnoDB...

    还在用if(obj!=null)做非空判断,带你快速上手Optional

    主要介绍了还在用if(obj!=null)做非空判断,带你快速上手Optional,文中通过示例代码介绍的非常详细,对大家的学习或者工作具有一定的参考学习价值,需要的朋友们下面随着小编来一起学习学习吧

    数据库NULL的用法.txt

    MySQL中如何使用NULL,把...update 表名 set a=NULL where 条件 把空字段作为查询条件的时候 select * from 表名 where a is NULL select * from 表名 where a != " NULL " select * from 表名 where a = " NULL

    java.lang.IllegalArgumentException:Input == null的异常处理

    Caused by: java.lang.IllegalArgumentException: input == null! at javax.imageio.ImageIO.read(ImageIO.java:1388) at com.pleanwar.fiying.FlyingObject.loadImage(FlyingObject.java:52) at ...

    JavaScript中为什么null==0为false而null大于=0为true(个人研究)

    生活中我们在不停的编写代码,写着JavaScript,很少有时间进行概念上的研究。我呢,今天闲来没啥事,研究了一下...在进行null>=0比较时,它是通过比较null到的答案,如果a=b u4e3afalse,如果a=b>0为true。所以 null

    二叉树的遍历与应用二叉链表

    if((node->lchild==NULL)&&(node->rchild==NULL)) return(1); else return(0); } /* function PrintLeafNode()功能:输出给定二叉树的叶子节点 */ void PrintLeafNode(BTree *header) { BTree * stack[MAX_NODE];/...

    javascript 处理null及null值示例

    代码如下: function dealNull(obj){ for(var i in... // 测试的对象 var a={}; a.aa=null; a.bb=’null’; a.c=1; a.b={}; a.b.aaa=null; a.b.bbb=’null’; a.b.c=1; a.array=[]; a.array.push({‘a’:null,’b’:’nu

    nick-offerman:废墟或炽烈的火焰

    尼克·奥弗曼你知道你怎么总是有可选值, a: A | null | undefined a: A | null | undefined a: A | null | undefined ,您想用它们来制作东西,但是如果它们什么都不是,则不要。 如果它们什么都不是,那么它们就...

    domino访问关系性数据库例子

    private static Connection conn = null; private static String aJdbcStr; private static String aUsername; private static String aPassword; private static String aDrv; public void NotesMain() { ...

    prefix cannot be "null" when creating a QName

    这个问题曾困扰了我一段时间,无意中看到了网上的一篇文章,看完后真是觉得惭愧啊!还是平时的粗心大意造成的啊!

    java期末考试试题(3)

     1) String str = null;  2) if ((str != null) && (str.length() > 10)) {  3) System.out.println("more than 10");  4) }  5) else if ((str != null) & (str.length() )) {  6) System.out.println(...

    数据结构-顺序表链表

    node *a=NULL,*b,*st,*alpha,*digit,*other; char c; while ((c=getchar())!='\n') /*读取字符并建表*/ { if (a==NULL) { a=malloc(sizeof(node)); st=a; a->d=c; } else{ b=malloc(sizeof(node)); b->d...

    c++简易校友录

    简易的校友录,运用了指针数组和类链表, void Add(node *&head, string na) ... a->next = NULL; return; } p = head->next; while (p->next != NULL) { p = p->next; } p->next = a;

    iOS-Null passed to a callee that requires a non-null argument警告

    Null passed to a callee that requires a non-null argument 此警告就是某属性说好的不能为空,你又在某地方写了XX = nil 所以冲突了 这个警告比较新,是xcode6.3开始 为了让OC也能有swift的?和!的功能,你在声明...

    C++课程设计——航空订票程序

    typedef struct airline{ ... if(a==NULL) a->next=NULL; return a; } customer *start_cus() { customer *c; c=(customer*)malloc(sizeof(customer)); if(c==NULL) c->next=NULL; return c; }

    浅析为什么a=”abc” 不等于 a=new String(“abc”)

    a="abc" typeof a //string b=new String("abc") typeof b // object a==b //true a===b //false 但是为什么呢?看了很多书,问了好几个大神,其实自己还是稀里糊涂的。这里记录一下,备查。 在js中,区分原始资料...

    Java测试题2答案

     } } <br>答案::填空第1题 x=10,a=3,b=4,c=5 填空第2题 java.util 填空第3题 (public )(static )(void)(main)(String args[]) 填空第4题 1 填空第5题

    win10 null.sys 文件 fatal:open /dev/null or dup failed: No such file or directory

    win10安装git报错 fatal:open /dev/null or dup failed: No such file or directory错误,将该文件复制到C:\Windows\System32\drivers 替换掉原有的null.sys文件重启即可

Global site tag (gtag.js) - Google Analytics