Absolute Difference of all pairwise consecutive elements in an array | Java program to print the absolute difference of the consecutive elements ; Function to print pairwise absolute difference of consecutive elements ; absolute difference between consecutive numbers ; Driver Code
class GFG { static void pairwiseDifference ( int arr [ ] , int n ) { int diff ; for ( int i = 0 ; i < n - 1 ; i ++ ) { diff = Math . abs ( arr [ i ] - arr [ i + 1 ] ) ; System . out . print ( diff + " ▁ " ) ; } } public static void main ( String [ ] args ) { int arr [ ] = { 4 , 10 , 15 , 5 , 6 } ; int n = arr . length ; pairwiseDifference ( arr , n ) ; } }