当前位置:网站首页>Error: symbol not found
Error: symbol not found
2022-07-06 12:59:00 【Non wind thought】
Error message
StringTest_2.java:25: error : No symbols found
while((index=indexOf(key))!=-1)
^
Symbol : Method indexof(String)
Location : class StringTest_2
1 A mistake
The code is as follows
public class StringTest_2
{
public static void main(String[] args)
{
String str="abcbjfbeabcjefjabcjepofkjabcniabc";
String key="abc";
int count=getKeyStringCount(str,key);
System.out.println("count="+count);
}
public static int getKeyStringCount(String str,String key)
{
// Define counters
int count=0;
// Define variable records key Position of appearance
int index=0;
while((index=indexOf(key))!=-1)
{
str=str.substring(index+key.length());
count++;
}
return count;
}
}
Common symbols that cannot be found are matching errors or undefined symbols , I checked the symbols and found no errors , Tried the guide bag again , All useless .
Found behind while((index=indexOf(key))!=-1) In a sentence indexOf(key) of no avail str Object call ,int indexOf(String str) The function of is to return the first occurrence of the specified string in the index of the string , Without calling the string object, its function cannot be realized !
resolvent
So it's going to be while((index=indexOf(key))!=-1)
Change to while((index=str.indexOf(key))!=-1)
边栏推荐
- [algorithm] sword finger offer2 golang interview question 7: 3 numbers with 0 in the array
- 记录:初次cmd启动MySQL拒接访问之解决
- FairyGUI复选框与进度条的组合使用
- 染色法判定二分图
- Unity3D,阿里云服务器,平台配置
- MySQL performance tuning - dirty page refresh
- Theoretical derivation of support vector machine
- Unity3d camera, the keyboard controls the front and rear left and right up and down movement, and the mouse controls the rotation, zoom in and out
- Comparative analysis of the execution efficiency of MySQL 5.7 statistical table records
- [GNSS data processing] Helmert variance component estimation analysis and code implementation
猜你喜欢
[algorithm] sword finger offer2 golang interview question 13: sum of numbers of two-dimensional submatrix
Fabrication d'un sac à dos simple fairygui
Force buckle 1189 Maximum number of "balloons"
MySQL shutdown is slow
【无标题】
Unity3D,阿里云服务器,平台配置
[algorithm] sword finger offer2 golang interview question 3: the number of 1 in the binary form of the first n numbers
The master of double non planning left the real estate company and became a programmer with an annual salary of 25W. There are too many life choices at the age of 25
FairyGUI增益BUFF數值改變的顯示
[algorithm] sword finger offer2 golang interview question 2: binary addition
随机推荐
isEmpty 和 isBlank 的用法区别
Office prompts that your license is not genuine pop-up box solution
Introduction to the daily practice column of the Blue Bridge Cup
[rtklib 2.4.3 B34] version update introduction I
Employment of cashier [differential constraint]
C programming exercise
[algorithme] swordfinger offer2 golang question d'entrevue 2: addition binaire
Fairygui loop list
基本Dos命令
Naive Bayesian theory derivation
FairyGUI复选框与进度条的组合使用
FairyGUI条子家族(滚动条,滑动条,进度条)
Database table splitting strategy
Containers and Devops: container based Devops delivery pipeline
Guided package method in idea
[算法] 剑指offer2 golang 面试题5:单词长度的最大乘积
Theoretical derivation of support vector machine
Halcon knowledge: gray_ Tophat transform and bottom cap transform
Shortest Hamilton path (pressure DP)
[算法] 剑指offer2 golang 面试题12:左右两边子数组的和相等