[英]What is the difference between constant variables and final variables in java?
[英]What is the difference between multiplying final and non final int variables?
考慮一下此代碼段
public class ConstantFolding {
static final int number1 = 5;
static final int number2 = 6;
static int number3 = 5;
static int number4 = 6;
public static void main(String[ ] args) {
int product1 = number1 * number2; //line A
int product2 = number3 * number4; //line B
}
}
標記為A的線和標記為B的線有什么區別?
沒有區別, product1
和product2
都等於30。
收到您的消息是因為您不能在沒有任何解釋的情況下發布代碼聲明。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.