Truth is, we'll need
much more context than that snippet to help you restructure your code without making very wild assumptions. Please
edit your question to include
at least the whole method, ideally the whole class - the fact that you have variables named
questionXAnswer
is a design smell that we unfortunately cannot address in the current state of the question. Also, please edit your title to tell us what your code is doing, not what you want to improve in it. —
Mat's Mug ♦ 1 min ago