How do I get a index on an array by using the value name.
And how to I get the value name by using the index number?
Printable View
How do I get a index on an array by using the value name.
And how to I get the value name by using the index number?
Is this an array or array list?
Say its an array.
String[] someArray = {"dog", "cat"};
in order to access objects knowing their index you can just say
String animal = someArray[0];
Knowing this, you should be able to figure out how to do so knowing the value and not the index.
sso i got to do a for looplike:
?Code:for (int x = 0;x<someArray.length;x++){
if ( someArray[x].equals("myname")){
...
Yes.
Also read the tutorial.
Did you try anything? Just post here so you can have comments on it from our members here, much effective way to learn a lot. :)