当前位置:网站首页>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)
边栏推荐
- 雇佣收银员【差分约束】
- Unity3d makes the registration login interface and realizes the scene jump
- The port is occupied because the service is not shut down normally
- Game 280 weekly
- Unity3d, Alibaba cloud server, platform configuration
- [Chongqing Guangdong education] reference materials for regional analysis and planning of Pingdingshan University
- Office提示您的许可证不是正版弹框解决
- Guided package method in idea
- The earth revolves around the sun
- Basic DOS commands
猜你喜欢
FairyGUI簡單背包的制作
[dry goods] cycle slip detection of suggestions to improve the fixed rate of RTK ambiguity
Wechat applet development experience
[Chongqing Guangdong education] Shandong University College Physics reference materials
Theoretical derivation of support vector machine
The earth revolves around the sun
《软件测试》习题答案:第一章
[算法] 剑指offer2 golang 面试题13:二维子矩阵的数字之和
[algorithm] sword finger offer2 golang interview question 9: subarray with product less than k
[算法] 剑指offer2 golang 面试题12:左右两边子数组的和相等
随机推荐
MySQL shutdown is slow
平衡二叉树详解 通俗易懂
[算法] 剑指offer2 golang 面试题3:前n个数字二进制形式中1的个数
[算法] 剑指offer2 golang 面试题8:和大于或等于k的最短子数组
使用rtknavi进行RT-PPP测试
记录:动态Web项目servlet访问数据库404错误之解决
Unity3D,阿里云服务器,平台配置
第一人称视角的角色移动
【干货】提升RTK模糊度固定率的建议之周跳探测
Fairygui character status Popup
WSL common commands
音乐播放(Toggle && PlayerPrefs)
[算法] 剑指offer2 golang 面试题4:只出现一次的数字
2022国赛Re1 baby_tree
Knowledge system of digital IT practitioners | software development methods -- agile
wsl常用命令
Edit distance (multi-source BFS)
FairyGUI按钮动效的混用
Meanings and differences of PV, UV, IP, VV, CV
[algorithm] sword finger offer2 golang interview question 6: sum of two numbers in the sorting array