当前位置:网站首页>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)
边栏推荐
- [算法] 劍指offer2 golang 面試題2:二進制加法
- 地球围绕太阳转
- [算法] 剑指offer2 golang 面试题5:单词长度的最大乘积
- Edit distance (multi-source BFS)
- 【干货】提升RTK模糊度固定率的建议之周跳探测
- [algorithm] sword finger offer2 golang interview question 8: the shortest subarray with a sum greater than or equal to K
- wsl常用命令
- 记录:newInstance()过时的代替方法
- [Chongqing Guangdong education] reference materials for regional analysis and planning of Pingdingshan University
- 341. Flatten nested list iterator
猜你喜欢
[算法] 剑指offer2 golang 面试题4:只出现一次的数字
What are the advantages of using SQL in Excel VBA
rtklib单点定位spp使用抗差估计遇到的问题及解决
《软件测试》习题答案:第一章
Unity3d makes the registration login interface and realizes the scene jump
[algorithm] sword finger offer2 golang interview question 6: sum of two numbers in the sorting array
Excel导入,导出功能实现
闇の連鎖(LCA+树上差分)
地球围绕太阳转
Code example of MATLAB reading GNSS observation value o file
随机推荐
The service robots that have been hyped by capital and the Winter Olympics are not just a flash in the pan
How to improve the deletion speed of sequential class containers?
微信小程序开发心得
FairyGUI复选框与进度条的组合使用
[Chongqing Guangdong education] reference materials for regional analysis and planning of Pingdingshan University
FGUI工程打包发布&导入Unity&将UI显示出来的方式
Compile GDAL source code with nmake (win10, vs2022)
VLSM variable length subnet mask partition tips
InnoDB dirty page refresh mechanism checkpoint in MySQL
地球围绕太阳转
错误: 找不到符号
FairyGUI人物状态弹窗
Unity3d makes the registration login interface and realizes the scene jump
On March 15, the official version of go 1.18 was released to learn about the latest features and usage
Teach you to release a DeNO module hand in hand
Comparative analysis of the execution efficiency of MySQL 5.7 statistical table records
Dark chain lock (lca+ difference on tree)
(core focus of software engineering review) Chapter V detailed design exercises
Office prompts that your license is not genuine pop-up box solution
[untitled]