作者andrewhanks (阿达)
看板java
标题[问题] 有关下列的程式码
时间Sun Jan 17 02:40:55 2010
忘了说明一下
我的这段程式的用意是
有一段字串
然後里面有三种资料
各别都分别以"\n"分开
我想要一个一个字元扫
在第一个"\n"之前的就分到第一种资料
在第二个"\n"之前的就分到第二种资料
在第三个"\n"之前的就分到第三种资料
在第四个"\n"之前的就分到第一种资料
以此类推
for(a=0; a<information1.length(); a++){
switch(temp%3){
case 0:
counttemp=0;
if(information1.charAt(a) != '\n'){
source[temp].charAt(counttemp) = information1.charAt(a);
counttemp++;
}
else{
sourcetemp++;
}
break;
case 1:
counttemp1=0;
if(information1.charAt(a) != '\n'){
destination[temp].charAt(counttemp1) = information1.charAt(a);
counttemp1++;
}
else{
destinationtemp++;
}
break;
case 2:
if(information1.charAt(a) != '\n'){
count[temp]++;
}
else{
temp++;
}
break;
}
}
请问以上的程式码哪里有错吗?
不然
它怎麽会一直出现如下的错误讯息
.\my\ui\Mediator.java:311: unexpected type
required: variable
found : value
source[temp].charAt(counttemp) =
informa
tion1.charAt(a);
^
.\my\ui\Mediator.java:321: unexpected type
required: variable
found : value
destination[temp].charAt(counttemp1)
= i
nformation1.charAt(a);
^
2 errors
--
※ 发信站: 批踢踢实业坊(ptt.cc)
◆ From: 140.123.215.21
1F:→ yyc1217:你的counttemp1的型态是什麽? 01/17 02:43
2F:→ andrewhanks:counttemp和counttemp1都是int 01/17 02:47
※ 编辑: andrewhanks 来自: 140.123.215.21 (01/17 02:55)
3F:→ hilorrk:想想destination[temp].charAt()是什麽 01/17 04:58
4F:→ hilorrk:第一个问题同理 01/17 05:01
5F:→ andrewhanks:已解决 多谢 01/17 07:00