I have two arraylists. One is personalContactList. The other is businessContactList.
1. I want to take user input that references an object attribute (int),
2. Use it to determine which object is referenced,
3. Find the "type" attribute of that object,
4. Determine which arraylist the object belongs to, based on that type,
5. Use the if else/statement to print out some attributes that depends on which arraylist the object is in.
I believe the code successfully does 1-3, and probably 4. But there is a hangup on 5. I get an indexoutofbounds execption. Which I'm not sure I understand very well.
Also, I'm very new to programming, so I may be missing things that are very obvious to most of you all.
Here is the code--it's part of a switch statement:
case "c": { //some code here prints out a list boolean b = false; int g; while (b == false) { Scanner detailScanner = new Scanner(System.in); System.out.print("Enter a number to see details: "); g = detailScanner.nextInt(); if (personalContactList.get(g).type.equals("personal")) { System.out.println(personalContactList.get(g).type); } else { System.out.println(businessContactList.get(g).type); } b = true; } break;
Any suggestions?