Analysis of Algorithms | Big | Java program for the above approach ; Function to print all possible pairs ; Driver code ; Given array ; Store the size of the array ; Function Call
import java . lang . * ; import java . util . * ; class GFG { static void print ( int a [ ] , int n ) { for ( int i = 0 ; i < n ; i ++ ) { for ( int j = 0 ; j < n ; j ++ ) { if ( i != j ) System . out . println ( a [ i ] + " ▁ " + a [ j ] ) ; } } } public static void main ( String [ ] args ) { int a [ ] = { 1 , 2 , 3 } ; int n = a . length ; print ( a , n ) ; } }