String的indexOf()方法不就是做这个的吗?
解决方案 »
- int[] a=new int[]{1,2,3,4,5};和int[] a={1,2,3,4,5};有什么区别吗?
- 简单的重绘问题
- 编写一个应用程序,使用一个ArrayList演示Collection接口的功能。谢谢各位大侠!!我是初学者。
- 关于this关键字的一个疑问
- 字符串反向截取,我的程序怎么又错呢??????
- 新手求救
- rmi的codebase问题。Stub无法自动下载
- 我有个问题,关于jlist的ListSelectionListener事件
- JBuilder的问题求教
- 新手幼稚问题
- 请问在java中如何实现类的动态生成?谢谢
- 为什么执行repaint()后,不能清除原来所画的内容?
int i = 0;
i = s.indexOf(“789”);
则i得到值为6。
String String2 = ...;
int i = 0;
i = String1.indexOf(String2);if( i != -1 )
String1=" ";
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.
String String2 = ...;
int i = 0;
i = String1.indexOf(String2);if( i != -1 )
String1=" ";
xtky_limi(痛在心中笑在脸上) is true
java.lang.NullPointerException at delprog.delFile2.main(delFile2.java:29)Exception in thread "main"