#how to find the sum of two specific arraylist integers?

1 messages · Page 1 of 1 (latest)

oblique owlBOT
#

<@&987246399047479336> please have a look, thanks.

oblique owlBOT
#

While you are waiting for getting help, here are some tips to improve your experience:

Code is much easier to read if posted with syntax highlighting and proper formatting.

If nobody is calling back, that usually means that your question was not well asked and hence nobody feels confident enough answering. Try to use your time to elaborate, provide details, context, more code, examples and maybe some screenshots. With enough info, someone knows the answer for sure.

Don't forget to close your thread using the command </help-thread close:1027500463647621170> when your question has been answered, thanks.

fleet quartz
#

the goal is to find the sum of the second and third number inputted

manic glen
#

what are the indices of the second and third numbers?

rose zinc
#

the break keyword is not the right choice in this code since it exits the while loop. U could use another keyword in its place or restructure the logic.

manic glen
#

the break is here to exit an infinite loop

rose zinc
#

but its used wrong

manic glen
#

used wrong how?

rose zinc
#

because it doesnt add 0s to the list

manic glen
#

0 is used as a sentinel value, it doesn't need to be added to a list

rose zinc
#

could interpret it that way yea

#

but i would use something like exit instead

manic glen
#

also, adding 0 does nothing

manic glen
rose zinc
#

no i mean if scanner.nextLine() returns "exit"

slim totem
#

then u have to make ur reading a two stage process

#

scanner.nextLine() and put that into a string variable

#

now check if it's exit with a simple if

#

if it is, break ur loop and whatever

#

if its not, Integer.parseInt(...) the string variable and continue with ur current logic

tawdry cipher
slim totem
#

oh gosh, didn't even notice. sorry for the confusion