Win a copy of Kotlin in Action this week in the Kotlin forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

Invariants in Java  RSS feed

 
Vidya Shivram
Ranch Hand
Posts: 36
1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Can anyone  explain me invariant with an easy example ?
 
Stephan van Hulst
Saloon Keeper
Posts: 7797
142
  • Likes 3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Invariants are just properties of an object that hold under ALL circumstances. For instance:

Invariants can be any property you think of. For instance, an invariant for a game of Tic Tac Toe could be that the board is always square.
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!