Performance 性能差异

Performance 性能差异,performance,Performance,假设我写了这样的代码 if(i==100) { System.out.println("hello"); } if(i==100) System.out.println("hello"); 或者我写这样的代码 if(i==100) { System.out.println("hello"); } if(i==100) System.out.println("hello"); 上述两种代码的性能和效率是否会有任何差异?性能不会有任何差异,只是如果去掉括号,可读性会降

假设我写了这样的代码

if(i==100)

{
    System.out.println("hello");
} 
if(i==100) System.out.println("hello");
或者我写这样的代码

if(i==100)

{
    System.out.println("hello");
} 
if(i==100) System.out.println("hello");

上述两种代码的性能和效率是否会有任何差异?

性能不会有任何差异,只是如果去掉括号,可读性会降低。另外,因为您需要知道,只会执行条件后的第一行

性能不会有任何差异,只有去掉括号后可读性会降低。另外,因为您需要知道,只会执行条件后的第一行

为什么会有任何区别呢?有可能(甚至有可能)编译器在前端之后的各个阶段甚至无法分辨出差异。为什么会有任何差异?有可能(甚至有可能)编译器在前端之后的各个阶段甚至无法分辨出它们之间的区别。