Online Course Discussion Forum

AP CS A question about FRQ

 
 
WangDr. Kevin的头像
Re: AP CS A question about FRQ
WangDr. Kevin - 2023年04月25日 Tuesday 12:34
 

In Java source code, the line break, tab, and the space characters are all treated as "white space", and don't affect syntax. So if you need to break a line in your code, there's no problem.  Just don't break up a long variable name, or a double-quoted String.  You may write 

for (int i=0; i< 100; i++) {sum += i;}

or you may write

for (
int i=0;
i < 100;
i++)
{
sum +=
i;
}

and it will be the same. How you arrange the code in a prettier way is a matter of style. A good style is easier for maintenance.  For the exam, as long as you have the correct code and correct syntax, and your code is not too messy in style, it should be okay.