简体   繁体   中英

I am trying to find the specific character within a String Array. What must I end up using?

Below is the code.\\ I imagine you use a for loop and then another but I cannot seem to make it work. I attempted research however most topics were too complex since I am a novice. I'm trying to find a way to get the fifth character out of each string within the variable. I'll use the information given to me so i can then solve the rest of my program. I have more to do

public static void main (String[]args)
{
     String[] decoder = {"Nexa2f5", "Z52Bizlm" , "Diskapr" , "emkem9sD", "LaWYrUs", "dAStn78L", "mPTuriye", "aaeeiuUu", "IL8Ctmpn"};
     int character = 4;
     for(int i=0; i<=decoder.length-1; i++)
     {

     }
}

I am trying to get the third and fourth characters of the odd numbered Strings. I am trying to put the letters into an array and decode the message. I am also trying to print the 5th character of all other words. I'm having issues commenting right and I've tried to reply a couple times but no dice.

Within your for loop use the array indexing notation. For example, String current = decoder[0] results in current having the value Nexa2f5 . Once you have the String Object (in my example, I named it current ) you can use the charAt() method shown in the String class documentation to get the 4th and 5th characters. If you need more help than that, read my comments then update your code and ask another question.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM