How to Reverse an int Array in Java with Example

There are multiple ways we can perform how to reverse an array in java with example. Reversing an array is an easy question. Let understand the question through the example :

Input    : {3, 8, 5, 7, 4}
Output : {4, 7, 5, 8, 3}

Input     : {10, 54, 23, 89, 97, 2}
Output  : {2, 97, 89, 23, 54, 10}

Read Also :   How to reverse a string in java with Example

Pseudo Code for Reverse Array in Java Method 1:

1. Swap the values of left indices with the right indices till the mid element.

Difference between Yield and Join Method in Java with Example

Multi-threading is a hot topic among investment banks interview. Difference between yield and join method is more of a theoretical question. I have already discussed difference between sleep and wait method in java.

Read Also :  Difference between Wait and Sleep method in Java

Difference between Yield and Join method in Java with Example

1.  Purpose : Yield in english means to give up or to surrender. Yield means currently executing thread gives chance to the threads that have equal priority in the Thread-pool.Yield does not guarantee that it will change the state of the currently executing thread to runnable state immediately.
If a join is called on a thread instance than it can be used to join the start of a thread's execution to the end of another thread's execution, such that a thread will not start running until another thread has ended.

2. State change :  Yield changes the state from running to runnable. If the method join() called on the