Is there a Java equivalent - specifically on Android - for VB.NET's Static
keyword? For those not familiar with VB.NET, take the following code snippet...
Sub MyFunc()
Static myvar As Integer = 0
myvar += 1
End Sub
The Static
keyword makes it so myvar retains its value between subsequent calls to MyFunc.
So after each of three calls to MyFunc, myvar's value would be: 1
, 2
and 3
.
How do you make a cross-call persistent variable within a method in Java? Can you?