public static Stack < String > reversePath ( List < String > pathParts ) { Stack < String > pathStack = new Stack < String > ( ) ; if ( pathParts != null ) { // Needs first extra argument at top of the stack for ( int i = pathParts . size ( ) - 1 ; i >= 0 ; i -- ) { pathStack . push ( pathParts . get ( i ) ) ; } } return pathStack ; }
Reverse path and return as a stack . First path element is on top of the stack .