| Author |
casting Objects
|
Abiodun Adisa
Ranch Hand
Joined: Jan 17, 2002
Posts: 495
|
|
I am receiving an Object from this method public void validate(FacesContext arg0, UIComponent arg1, Object arg2) throws ValidatorException {} and on looking into arg2 using Debug variables i noticed it contains two ArrayList, it shows arg2-------------------------------->Object[2] [0]------------------------------>ArrayList<E> [1]------------------------------>ArrayList<E> Problem is what do i cast arg2 with in order to obtain my two ArrayList?
|
 |
Paul Clapham
Bartender
Joined: Oct 14, 2005
Posts: 16483
|
|
|
You would be better off to have your debugger find out what class the object belongs to. Then cast it to that class.
|
 |
Abiodun Adisa
Ranch Hand
Joined: Jan 17, 2002
Posts: 495
|
|
Originally posted by Paul Clapham: You would be better off to have your debugger find out what class the object belongs to. Then cast it to that class.
Thats what i did when i put a debugger on arg2 it showed Object[2] and when i expanded it i got [0]------------------------------>ArrayList<E> [1]------------------------------>ArrayList<E>
|
 |
Henry Wong
author
Sheriff
Joined: Sep 28, 2004
Posts: 16695
|
|
arg2-------------------------------->Object[2] [0]------------------------------> ArrayList<E> [1]------------------------------> ArrayList<E> Problem is what do i cast arg2 with in order to obtain my two ArrayList?
Object arr[] = (Object []) arg2; ArrayList<E> firstArrayList = (ArrayList<E>) arr[0]; ArrayList<E> secondArrayList = (ArrayList<E>) arr[1]; Henry [ March 06, 2008: Message edited by: Henry Wong ]
|
Books: Java Threads, 3rd Edition, Jini in a Nutshell, and Java Gems (contributor)
|
 |
 |
|
|
subject: casting Objects
|
|
|