Can we change the position of the object?


I know google translate does the bare minimum job of translating a sentence
into Japanese. The original sentence was, "I had to hit my head on the table."
which was translated into "テーブルに頭を打たなければなりませんでした。" I tried changing the
position of the object because it made more sense to me. The translated
sentence I came up with was, "頭をテーブルに打たなければなりませんでした。" Can we use this instead?

Also, "打たなければなりませんでした。" seems a bit confusing. It translates to "I had to
hit." but doesn't なければ mean "If not" and I don't know why "なりませんでした" was used.




Actually the meaning of the two Japanese sentences you wrote are the same. In
simple sentences like this, the parts with the particle に、を、で are usually
freely interchangeable, and do not affect the meaning. The meaning of
リンゴをカバンに入れました and カバンにリンゴを入れました are exactly the same.

Note that for longer sentences with more complicated structures (for example
when explaining reasons, order of actions, etc), changing the orders may also
change the meaning of the sentences.

For なければなりませんでした please refer to the link provided in Chocolate's comment.




Actually the meaning of the two Japanese sentences you wrote are the same. In
simple sentences like this, the parts with the particle に、を、で are usually
freely interchangeable, and do not affect the meaning. The meaning of
リンゴをカバンに入れました and カバンにリンゴを入れました are exactly the same.

Note that for longer sentences with more complicated structures (for example
when explaining reasons, order of actions, etc), changing the orders may also
change the meaning of the sentences.

For なければなりませんでした please refer to the link provided in Chocolate's comment.

