swap two variables with the use of temp. Now, it's time to see how to swap two variables without the use of a temporary variable. This is just easy if you take a look. It is all simple logic. The example below shows that. It is given with explanation of every statement for a better understand.
ClassCastExceptionis an unchecked exception i.e. it is not identified at compile time. The
ClassCastExceptionis since JDK 1.0
Topics Exception Handling
Topics Playing with Numbers