我的数组是Object[] Words;
有
Words[0]=Apple-Alim,AlimniiMod;
Words[1]=Anxious-SanaaZowson,SetgelTugshse;
Words[2]=Car-Mashin,MashinTereg,Wagon etc..
我如何在'-'
答案 0 :(得分:0)
将其转换为String[]
数组并尝试使用它,
String[] wordArray= Arrays.copyOf(Words, Words.length, String[].class);
使用indexOf()
方法查找-
char的出现次数。使用subString()
答案 1 :(得分:0)
public static void main(String[] args) {
Object[] words = new Object[5];
words[0] = new String("Apple-Alimnii, jskdhj");
for(int i = 0; i < ((String)words[0]).length(); i++) {
System.out.print(((String)words[0]).charAt(i));
if(((String)words[0]).charAt(i) == '-')
break;
}
}