当前位置:网站首页>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)
边栏推荐
- 使用rtknavi进行RT-PPP测试
- [algorithm] sword finger offer2 golang interview question 8: the shortest subarray with a sum greater than or equal to K
- Agile development helps me
- 记录:动态Web项目servlet访问数据库404错误之解决
- How to improve the deletion speed of sequential class containers?
- C code implementation of robust estimation in rtklib's pntpos function (standard single point positioning spp)
- (core focus of software engineering review) Chapter V detailed design exercises
- Particle system for introduction to unity3d Foundation (attribute introduction + case production of flame particle system)
- 堆排序【手写小根堆】
- Itext 7 生成PDF总结
猜你喜欢
RTKLIB: demo5 b34f.1 vs b33
Rt-ppp test using rtknavi
FairyGUI摇杆
FairyGUI条子家族(滚动条,滑动条,进度条)
(core focus of software engineering review) Chapter V detailed design exercises
In 2020, the average salary of IT industry exceeded 170000, ranking first
编辑距离(多源BFS)
Mixed use of fairygui button dynamics
[算法] 剑指offer2 golang 面试题3:前n个数字二进制形式中1的个数
Unity3d makes the registration login interface and realizes the scene jump
随机推荐
Fabrication d'un sac à dos simple fairygui
Implementation of Excel import and export functions
Detailed explanation of balanced binary tree is easy to understand
Dark chain lock (lca+ difference on tree)
Problems and solutions of robust estimation in rtklib single point location spp
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
记录:newInstance()过时的代替方法
MySQL 三万字精华总结 + 面试100 问,吊打面试官绰绰有余(收藏系列
Theoretical derivation of support vector machine
Unity3D基础入门之粒子系统(属性介绍+火焰粒子系统案例制作)
[algorithm] sword finger offer2 golang interview question 12: the sum of the left and right sub arrays is equal
wsl常用命令
Realization of the code for calculating the mean square error of GPS Height Fitting
Office prompts that your license is not genuine pop-up box solution
[算法] 剑指offer2 golang 面试题7:数组中和为0的3个数字
【干货】提升RTK模糊度固定率的建议之周跳探测
服务未正常关闭导致端口被占用
[算法] 剑指offer2 golang 面试题10:和为k的子数组
Particle system for introduction to unity3d Foundation (attribute introduction + case production of flame particle system)
Prove the time complexity of heap sorting