看板 java 關於我們 聯絡資訊
忘了說明一下 我的這段程式的用意是 有一段字串 然後裡面有三種資料 各別都分別以"\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
yyc1217:你的counttemp1的型態是什麼? 01/17 02:43
andrewhanks:counttemp和counttemp1都是int 01/17 02:47
※ 編輯: andrewhanks 來自: 140.123.215.21 (01/17 02:55)
hilorrk:想想destination[temp].charAt()是什麼 01/17 04:58
hilorrk:第一個問題同理 01/17 05:01
andrewhanks:已解決 多謝 01/17 07:00