【发布时间】:2019-06-20 10:43:13
【问题描述】:
诸如方法名称或参数名称之类的内容对条目在堆栈上占用多少内存有影响吗?
我知道像ints 这样的原始参数确实会占用内存,但我想知道我是否可以通过简洁地命名我的方法和参数名称来节省内存,无论多么微不足道,或者我是否应该给他们足够长的名字来描述他们的工作。
public static int convertSomeIntegerValueToSomeOtherIntegerValueByMethodOfDividingTheOriginalIntegerByTwoAndRoundingTheOutputBecauseItIsAnInteger(int veryVerboseIntegerValueWithAVeryLongParameterNameSoItCanBeDividedByTwo){
return veryVerboseIntegerValueWithAVeryLongParameterNameSoItCanBeDividedByTwo/2;
}
public static int divTwo(int a){
return a/2;
}
这两种方法除了源代码的文件大小有什么区别吗?
另外,这些方法名是否会使编译后的代码变大?
【问题讨论】:
-
我是这里的新手,所以如果您投反对票,请留言说明原因。谢谢!
-
最后一个问题,你为什么不把这些放在一个类里,编译看看?