The BMW 320i has a 2.0L turbocharged engine. HUZZAH! It makes some sense. The 328i also has a 2.0L turbocharged engine, and the 328d has a 2.0L turbocharged diesel engine. Meanwhile, the 335i is powered by a 3.0L turbocharged engine.
Once upon a time, the last two digits and the following letter told someone exactly what was powering said car. The last two digits, referred to the engine size, and the letters told you about features like fuel injection (denoted by an "i"). BMW moved away from this when it started to offer turbocharged engines, since "t" was already taken by touring models and that left no way to differentiate them from naturally aspirated Bimmers without an arbitrary increase in what was the displacement number.
Now rumor has it that the company has decided that the nomenclature is beyond salvage, and is just going to start using increments of ten, because why the hell not?
320i = 320i
328i = 330i
335i = 340i