当前位置:网站首页>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 6: sum of two numbers in the sorting array
- [算法] 剑指offer2 golang 面试题10:和为k的子数组
- Introduction to the daily practice column of the Blue Bridge Cup
- Acwing-116 pilot brother
- GNSS positioning accuracy index calculation
- [算法] 剑指offer2 golang 面试题8:和大于或等于k的最短子数组
- 【无标题】
- Realization of the code for calculating the mean square error of GPS Height Fitting
- 1041 be unique (20 points (s)) (hash: find the first number that occurs once)
- [algorithm] sword finger offer2 golang interview question 9: subarray with product less than k
猜你喜欢
[算法] 剑指offer2 golang 面试题1:整数除法
PR 2021 quick start tutorial, first understanding the Premiere Pro working interface
Fundamentals of UD decomposition of KF UD decomposition [1]
MySQL 三万字精华总结 + 面试100 问,吊打面试官绰绰有余(收藏系列
服务未正常关闭导致端口被占用
The earth revolves around the sun
Matlab读取GNSS 观测值o文件代码示例
第一人称视角的角色移动
FairyGUI簡單背包的制作
Combination of fairygui check box and progress bar
随机推荐
Mixed use of fairygui button dynamics
《软件测试》习题答案:第一章
闇の連鎖(LCA+树上差分)
GPS高程拟合抗差中误差的求取代码实现
[rtklib 2.4.3 B34] version update introduction I
[algorithm] sword finger offer2 golang interview question 10: subarray with sum K
音乐播放(Toggle && PlayerPrefs)
Devops' future: six trends in 2022 and beyond
地球围绕太阳转
FairyGUI簡單背包的制作
FairyGUI循环列表
Pride-pppar source code analysis
GNSS positioning accuracy index calculation
Compile GDAL source code with nmake (win10, vs2022)
3月15号 Go 1.18 正式版发布 了解最新特色以及使用方法
Combination of fairygui check box and progress bar
MySQL performance tuning - dirty page refresh
[算法] 剑指offer2 golang 面试题8:和大于或等于k的最短子数组
Fairygui joystick
Role movement in the first person perspective