当前位置:网站首页>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, Alibaba cloud server, platform configuration
- 音乐播放(Toggle && PlayerPrefs)
- FairyGUI条子家族(滚动条,滑动条,进度条)
- 3月15号 Go 1.18 正式版发布 了解最新特色以及使用方法
- Prove the time complexity of heap sorting
- PRIDE-PPPAR源码解析
- 【干货】提升RTK模糊度固定率的建议之周跳探测
- [算法] 剑指offer2 golang 面试题9:乘积小于k的子数组
- The port is occupied because the service is not shut down normally
- 1041 be unique (20 points (s)) (hash: find the first number that occurs once)
猜你喜欢

MySQL shutdown is slow

Unity3D,阿里云服务器,平台配置

Excel导入,导出功能实现

Office提示您的许可证不是正版弹框解决

Fabrication of fairygui simple Backpack

堆排序【手写小根堆】

Teach you to release a DeNO module hand in hand

闇の連鎖(LCA+树上差分)

Naive Bayesian theory derivation

The service robots that have been hyped by capital and the Winter Olympics are not just a flash in the pan
随机推荐
[untitled]
FairyGUI簡單背包的制作
异常:IOException:Stream Closed
1041 be unique (20 points (s)) (hash: find the first number that occurs once)
MySQL 三万字精华总结 + 面试100 问,吊打面试官绰绰有余(收藏系列
Devops' future: six trends in 2022 and beyond
MySQL shutdown is slow
The service robots that have been hyped by capital and the Winter Olympics are not just a flash in the pan
记录:下一不小心写了个递归
Matlab读取GNSS 观测值o文件代码示例
[algorithm] sword finger offer2 golang interview question 8: the shortest subarray with a sum greater than or equal to K
How to reduce the shutdown time of InnoDB database?
VLSM variable length subnet mask partition tips
Usage differences between isempty and isblank
InnoDB dirty page refresh mechanism checkpoint in MySQL
【GNSS数据处理】赫尔默特(helmert)方差分量估计解析及代码实现
Theoretical derivation of support vector machine
Fairygui joystick
记录:初次cmd启动MySQL拒接访问之解决
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