Online Course Discussion Forum

AP CS A question about FRQ

 
 
Picture of Dr. Kevin Wang
Re: AP CS A question about FRQ
by Dr. Kevin Wang - Tuesday, April 25, 2023, 12:34 PM
 

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.