Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Trouble Casting from Object to String[][]

Status
Not open for further replies.

justride

Programmer
Jan 9, 2004
251
0
0
US
Hello,

I have a hashtable of keys/values where the keys are strings and the values are 2D String arrays, String[][].

If I pull a value, String[][], on a given key String, I get a result of type Object. I need to, I guess, cast this Object to a String[][] because I need to pass it so some method
Code:
void doSomething(String[][]){}

If I code something like:
Code:
doSomething(hashtable.get("key"));
I get "the method doSomething(Object)" is undefined.

I tried casting too, with a (String[][]) but that didnt work.

Any suggestions?

 
This works for me :

Code:
        public void bla(String[][] bla) {
                System.out.println("val : " +bla[0][0]);
        }

        public void doit()
                String[][] bla = new String[1][1];
                bla[0][0] = "Hello";

                Hashtable ht = new Hashtable();
                ht.put("bla", bla);

                bla((String[][])(ht.get("bla")));
         }

--------------------------------------------------
Free Java/J2EE Database Connection Pooling Software
 
I'll try again, I could have sworn thats the syntax I was using. Thanks for the tip, I will keep you posted.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top