我正在寫一個程序計算給定序列中氨基酸代碼的概率。當我嘗試從用戶的輸入,它顯示了以下錯誤獲得輸入字符串長度超過60
Exception in thread "main" java.lang.StringIndexOutOfBoundsException: String index out of range: 407
at java.lang.String.charAt(String.java:646)
at BNC.Sequence.<init>(Sequence.java:50)
at BNC.Navie_Bayesian_Classifier.main(Navie_Bayesian_Classifier.java:34)
407Java Result: 1
我的代碼是
try(Scanner scan=new Scanner(new File("F:\\Thiyaga\\ProteinSequence\\Test.txt")))
{
line = scan.nextLine().trim();
length=line.length();
// line=reader.readLine();
}
System.out.print(length);
for(i=0;i<20;i++)
{
count[i]=0;
probility[i]='\0';
}
for(int k=0;k<length;k++)
{
switch(line.charAt(k))
{
它顯示了在開關或長度誤差在
我輸入的這種形式
MVKETKFYDILGVPVTATDVEIKKAYRKCALKYHPDKNPSEEAAEKFKEASAAYEILSDPEKRDIYDQFGEDGLSGAGGAGGFPGGGFGFGDDIFSQFFGAGGAQRPRGPQRGKDIKHEISA SLEELYKGRTAKLALNKQILCKECEGRGGKKGAVKKCTSCNGQGIKFVTRQMGPMIQRFQTECDCHGTGDIIDPKDRCKSCNGKKVENERILEVHVEPGMKDGQRIVFKGEADQAPDVIPGDVVFIVSERPHKSFKRDGDDLVYEAEIDLLTAIAGGEFALEHVSGDWLKVGIVPGEVIAPGMRKVIEGKGMPIPKYGGYGNLIIKFTIKFPENHFTSEENLKKLEEILPPRIVPAIPKKATVDECVLADFDPAKYNRTRASRGGANYDSDEEEQGGEGVQCASQ
正是你的代碼是打破我不明白,什麼是你的代碼完全做的,其中的在線人數正在被討論。 – Sandeep
您是否在'for(int k = 0; k