至于内存,使用以下两个选项创建局部变量之间有什么区别:
选项1)
private String A, B;
选项2)
private String A;
private String B;
没有不同...
public class DiffFirst { private String A, B; }
VS
public class DiffSecond { private String A; private String B; }
我执行:
javac DiffFirst.java javac DiffSecond.java
然后:
javap -c DiffFirst.class javap -c DiffSecond.class
输出:
Compiled from "DiffFirst.java" public class DiffFirst { public DiffFirst(); Code: 0: aload_0 1: invokespecial #1 // Method java/lang/Object."":()V 4: return } Compiled from "DiffSecond.java" public class DiffSecond { public DiffSecond(); Code: 0: aload_0 1: invokespecial #1 // Method java/lang/Object." ":()V 4: return }
我会使用camelCase并调用那些变量a和b.