gpt4 book ai didi

java - 数组[++变量]代表什么?

转载 作者:行者123 更新时间:2023-12-01 07:47:42 24 4
gpt4 key购买 nike

示例代码如下:

static class stack 
{
int top=-1;
char items[] = new char[100];

void push(char x)
{
if (top == 99)
System.out.println("Stack full");
else
items[++top] = x;
}
}

当 items[++top] 发生时到底会发生什么?

最佳答案

这是预增量。它等于:

void push(char x) 
{
if (top == 99)
System.out.println("Stack full");
else {
top = top + 1;
items[top] = x;
}

}

关于java - 数组[++变量]代表什么?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/48282625/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com