if (youstring.indexOf("#")>0)
{System.out.println(youstring.indexOf("#"));}
{System.out.println(youstring.indexOf("#"));}
解决方案 »
- srping MVC 中的<spring:bind>数据绑定不上,求解
- spring注解
- Java连接Oracle数据库
- 求能跑起来的j2ee项目,直接100分
- 论坛或者留言板的表情添加
- 为什么我这个文本文件第一行读不出来?在线等
- 调用webservice时遇到的困难
- 大家都进来探讨一些这个Spring的问题
- 在servlet里用RequestDispatcher重定向到jsp出现乱码!!!
- 一个struts+sql server得分页(存储过程版) 源码
- J2EE的入门问题,散散分了
- 虚心请教各位高手,急盼回复:根据一周内某一天时间如何计算出前一周的周一和周五的具体时间值,并转化为诸如20030306这样的字符串!
{
char[] charr = yrstr.toCharArray(); for (int i=0; i<charr.length; i++)
if (charr[i] == c)
return i; // Return the position return -1; // No match
}应该就是这样的啦
public int indexOf(String str)
Returns the index within this string of the first occurrence of the specified substring. The integer returned is the smallest value k such that:
this.startsWith(str, k)
is true. Parameters:
str - any string.
Returns:
if the string argument occurs as a substring within this object, then the index of the first character of the first such substring is returned; if it does not occur as a substring, -1 is returned.
Throws:
NullPointerException - if str is null.--------------------------------------------------------------------------------indexOf
public int indexOf(String str,
int fromIndex)
Returns the index within this string of the first occurrence of the specified substring, starting at the specified index. The integer returned is the smallest value k for which:
k >= Math.min(fromIndex, str.length()) && this.startsWith(str, k)
If no such value of k exists, then -1 is returned. Parameters:
str - the substring for which to search.
fromIndex - the index from which to start the search.
Returns:
the index within this string of the first occurrence of the specified substring, starting at the specified index.
Throws:
NullPointerException - if str is null.