[英]I am trying to find the specific character within a String Array. What must I use?
Below is the code.\\ I imagine you use a for loop and then another but I cannot seem to make it work. 下面是代码。\\我想象您使用了一个for循环,然后使用了另一个,但是我似乎无法使其正常工作。 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.
我还试图打印所有其他单词的第5个字符。 I'm having issues commenting right and I've tried to reply a couple times but no dice.
我在评论时遇到问题,我尝试过几次答复,但没有骰子。
Here is what I would do: 这是我会做的:
String[] decoder = {"Nexa2f5", "Z52Bizlm" , "Diskapr" , "emkem9sD", "LaWYrUs", "dAStn78L", "mPTuriye", "aaeeiuUu", "IL8Ctmpn"};
for (String s: decoder){
String myChar = s.substring(4, 5);
// now continue to process myChar
}
class test {
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++)
{
String temp = decoder[i];
System.out.println(temp.substring(4,5));
}
}
}
for(String s : decoder) {
for(char c : s.toCharArray()) {
//loops through ever char of every string
}
}
char letter;
for(String s : decoder) {
if(s.length > 4) {
letter = s.chatAt(5);
}
}
Choose your weapon. 选择你的武器。 I'm not completely sure how you want to do this, but this is the format you'd want for looping through variables in an array.
我不确定要如何执行此操作,但这是您要遍历数组中变量的格式。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.