KnowledgeHub
Questions
Tags
Users
Search
Alex Rivera
|
Logout
Edit Question
Title
Body
I have a code like this int a,b; switch(whatever){ case 1: lots_of_lines_dealing_with_variable_a; case 2: same_lines_but_dealing_with_variable_b; } I thought of doing: int a,b; pointer_to_int p; switch(whatever){ case 1: p=a; case 2: p=b; } lots_of_lines_dealing_with_pointer_p; It would reduce the code to about half the lines, but Java doesn't allow pointers to integers. So, is there any way to approach this? Edit: The homework is much bigger than just this method. I need to Create a class called "DoubleList" which contains two linked lists in a single Vector. The integers I talk about are the pointers to the start of the Lists, which I need to move to other positions of the Lists when adding or removing elements to the Lists
Tags (comma-separated)
Save Edits
Cancel