Why did Serial.println print twice?

Here is my code:
void setup(){
Serial.begin(9600);
int a =2;
int b =2;
int c = a + b;
Serial.println(c);
}

void loop(){
}

Serial Monitor:
4
4

It is supposed to print '4' once, but it printed '4' twice... I just started learning arduino today. Thank you!

It shouldn't print 4 twice.

When you open the serial monitor it resets the Arduino, which was already running and had output a "4". Ideally this first output would be flushed and not appear, but it shows up sometimes. Other times you just get garbage characters. It's a minor flaw in the monitor tool.

Try this instead and you will see it's only printing once:

void setup(){
 Serial.begin(9600);
Serial.println("\nStarting the sketch...\n");
 int a =2;
 int b =2;
 int c = a + b;
 Serial.println(c);
}

void loop(){
}