MAIN FEEDS
Do you want to continue?
https://www.reddit.com/r/badcode/comments/gvf0dp/return_2/fspxtin/?context=3
r/badcode • u/[deleted] • Jun 02 '20
29 comments sorted by
View all comments
45
They probably intended for the variable to be static and never realised their mistake.
Edit: Wait, local static variables aren't legal in Java. This was probably written by someone coming from C
29 u/Exnixon Jun 02 '20 And even in C, the first invocation would return 2. 0 u/Lurchwart Jun 03 '20 And the second two 4 u/Dumbo14 Jun 03 '20 No, if the variable is static (in C at least) then every successive call to the function would return a incremented number.
29
And even in C, the first invocation would return 2.
0 u/Lurchwart Jun 03 '20 And the second two 4 u/Dumbo14 Jun 03 '20 No, if the variable is static (in C at least) then every successive call to the function would return a incremented number.
0
And the second two
4 u/Dumbo14 Jun 03 '20 No, if the variable is static (in C at least) then every successive call to the function would return a incremented number.
4
No, if the variable is static (in C at least) then every successive call to the function would return a incremented number.
45
u/Dumbo14 Jun 02 '20 edited Jun 02 '20
They probably intended for the variable to be static and never realised their mistake.
Edit: Wait, local static variables aren't legal in Java. This was probably written by someone coming from C