java - Best way to get value from Collection by index -


What's the best way to get value from java.util? Compilation by index?

You should not have avoided talking about a archive instructions Especially because it does not make sense for specific collections. For example, the order of a list is in some form, but not set .

  Archive & lt; String & gt; MyCollection = New Hashet & lt; String & gt; (); MyCollection.add ("hello"); MyCollection.add ("world"); {String AMM: Microlication} for {System.out.println ("elem =" + elem); } System.out.println ("myCollection.toArray () [0] =" + myCollection.toArray () [0]);  

gives me:

  elem = world elem = hello myCollection.toArray () [0] = world  
< P> when:

  myCollection = new arreelist & lt; String & gt; (); MyCollection.add ("hello"); MyCollection.add ("world"); {String AMM: Microlication} for {System.out.println ("elem =" + elem); } System.out.println ("myCollection.toArray () [0] =" + myCollection.toArray () [0]);  

gives me:

  elem = hello name = world myCollection.toArray () [0] = Hello  
< P> Why do you want to do this? Can not you just come back to the collection?


Comments

Popular posts from this blog

c++ - Linux and clipboard -

What is expire header and how to achive them in ASP.NET and PHP? -

sql server - How can I determine which of my SQL 2005 statistics are unused? -