title: Java equivalent to .NET System.InvalidOperationException
body: <p>I am not as familiar with Java's exception packages as with those of .NET. I'm in a situation where, if programming in C#, I would throw a <code>System.InvalidOperationException</code>. </p>
  
  <p>Before creating my own <code>java.lang.RuntimeException</code> subclass, I need to know if there is a similar exception type I should throw in Java.</p>
  
  <p>The exact scenario is:</p>
  
  <p>My class is a value object that provides an <code>int intValue()</code> method, returning an int. However, in some situations, the current value cannot be provided as an int, so this class also provides a <code>boolean isInteger()</code> to allow API users to know when <code>intValue()</code> can be safely invoked.</p>
  
  <p>If a caller calls <code>intValue()</code> when <code>isInteger()</code> is <code>false</code>, an exception should be thrown. </p>
  
  <p>And the question is: What type of exception?</p>
  
  <p>I know that this question might not have a <em>correct</em> answer, but considering that I don't have lots of experience designing Java APIs, I want to know from other Java developers what they would expect to be thrown in this scenario.</p>
  
  <p>thanks</p>