Class variable in Java have the same behavior as in Ruby?

Asked

Viewed 31 times

2

In Ruby a class variable that is modified by an object ends up modifying the value of all other objects instead of making a copy of that value. This also occurs in Java?

1 answer

1


In Java, class variables are declared with static. In this case, the object to which this variable refers will be the same for all instances of the class. Effectively, variables declared with static in Java are global.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.