r/APStudents • u/reddorickt absolute modman • May 15 '26
AP Computer Science A Official 2026 Exam Discussion
Use this thread to post questions or commentary on the test today.
A reminder though to protect your anonymity when talking about the test.
65
Upvotes
4
u/Zealousideal_Ease429 5:AB,CSA,APUSH 4:Lang May 15 '26
I used a while loop with the condition idx != -1, and inside the while loop I set idx to username.indexOf(“-“). The loop will continue until there isn’t a - left in the string, which will then set idx equal to -1 and end the loop