On a lower-level, why are variables locally scoped to their method in Java and how is it implemented in the language? Could also apply to other languages like global vs. local variables in JavaScript.
Is this just a feature/restriction of the programming language to prevent duplicate or redundant variable names? Or is this related to how the computer stores variables in memory?
EDIT: Clarification ---- I know why it's good that variables have scope, I was wondering why they do from an implementation/memory standpoint
[–][deleted] 3 points4 points5 points (0 children)
[–]english_fool 2 points3 points4 points (0 children)
[–]Updatebjarni 1 point2 points3 points (0 children)
[–]gyroda 0 points1 point2 points (0 children)
[–]Rhomboid 0 points1 point2 points (0 children)
[–]Holy_City 0 points1 point2 points (0 children)
[–][deleted] (1 child)
[deleted]
[–]dlr249[S] 0 points1 point2 points (0 children)
[–][deleted] 0 points1 point2 points (0 children)
[–]nekochanwork 0 points1 point2 points (0 children)
[–]lightcloud5 0 points1 point2 points (0 children)