You need to learn the rules about the endings. That means, you need to learn each noun's GENDER, and you need to learn its DECLENSION PATTERN.

Once you know if a noun is masc., fem., or neuter,...