Those who want to study in Sweden for longer than three months need a residence permit. To apply for such a permit, the person must first have been admitted to full-time studies in Sweden. The applicant must also demonstrate that he/she can support him/herself during their entire study period. Upper secondary school students and exchange students need to demonstrate that they have allowances for the planned study period.
Please visit the Swedish Migration Agency's website for more information: Residence permit for studies in Sweden – Swedish Migration Agency