Check if a Rook can reach the given destination in a single move | Java program for the above approach ; Function to check if it is possible to reach destination in a single move by a rook ; Driver code ; Given arrays
import java . util . * ; import java . lang . * ; class GFG { static String check ( int current_row , int current_col , int destination_row , int destination_col ) { if ( current_row == destination_row ) return " POSSIBLE " ; else if ( current_col == destination_col ) return " POSSIBLE " ; else return " NOT ▁ POSSIBLE " ; } public static void main ( String [ ] args ) { int current_row = 8 ; int current_col = 8 ; int destination_row = 8 ; int destination_col = 4 ; String output = check ( current_row , current_col , destination_row , destination_col ) ; System . out . println ( output ) ; } }