There are too many incorrect contents
Since there are too many incorrect contents from the beginning, from then on, I have to separately verify whether the lecture contents are true,
and I get to the point where I get confused whether I am listening to the lecture or checking for errors.
In particular, Array shows off its power in the part where memory allocation occurs during the compile stage.
It is also funny that it is allocated in the Stack memory area.
I would like to express my deepest condolences to the many students who listened to this lecture and made the interviewers laugh out loud,
and I hope that there will be no additional victims like me.
Additional.
The instructor left the following comment.
I would like to inform you that the contents of this Notion are also incorrect.
https://midi-mandolin-36f.notion.site/Array-33d866e5193f49789dd2079c75412f96?pvs=4
In "C language", "Static Array" can be stored anywhere in the process's data area (Stack, Data, Heap), and it depends on the developer's development intention (code).
// The code is as follows.
int[5]; // Stored in the Data area
int main() {
int[5]; // Stored in the Stack area
int* arr = (int*)malloc(5 * sizeof(int)); // Stored in the Heap area
// Memory is dynamically allocated, but the array itself is a Static Array.
}
If the proposition "Static arrays in the C language are allocated to stack memory during the compile phase." is true,
"int type variables in the C language are allocated to stack memory during the compile phase." is also true because it is the same mechanism.
"If you roll a dice, you get a 3. 1, 2, 4, 5, and 6 are exceptions." Is the explanation correct?
"When you roll a dice, the number that comes out is a random number between 1 and 6."
Students can decide whether the explanation is correct.
Addition.
The instructor has already modified Notion again.
According to the logic of the Notion content, in Java, not only Arrays but all data structures are stored in the Heap.
As for the professor's answer below... I don't know what you are trying to say.
[Specific data structures and build stages, process memory area allocation are not related] is correct.
Based on the C language, you wrote 1, 2, and 3 well, but I don't know why the conclusion is suddenly [Based on the C language, arrays are allocated in the stack area during the compile stage].
Anyway, thank you for your hard work.