To determine compatibility, you need to know the *exact* engine codes for both cars. These codes (often a combination of letters and numbers) are usually found on a sticker on the engine itself, or in the owner's manual. Even with matching engine codes, minor differences in year-specific parts might require adjustments.
Simply having the same displacement (e.g., both 2.2L engines) isn't sufficient; internal components, mounting points, and even the computer systems controlling the engine can differ. You'd need to compare the specifics to be sure.