Be careful not to think that a variable declared in a Sub with Private does not affect a possible variable with the same name (and type) declared at module level. Changing the value of this variable in the Sub changes the value of the one declared at the module level, as they are the same variable.
By default it is Public.
BTW, the function in the first post is unnecessarily long:
B4X:
Sub GetMaxValue(arrInt() As Int) As Int
Dim iResult As Int
For i = 1 To arrInt.Length - 1
iResult = Max(iResult, arrInt(i))
Next
Return iResult
End Sub