Win a copy of The Little Book of Impediments (e-book only) this week in the Agile and Other Processes forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

MethodNotFoundError

 
bhuwan tiwari
Greenhorn
Posts: 19
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
My applet program using StringBuffer class is compiling fine.
But while running it gives "MethodNotFoundError" for method
delete() and substring(), while appened()method is working fine.
 
Suneel Setlur
Ranch Hand
Posts: 202
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi
Can you just put in you code also.
It would be easier.
I hope you have you used StringBuffer.delete() and StringBuffer.substring().

------------------
Suneel
 
Golam Newaz
Ranch Hand
Posts: 64
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,
I am Sayeed. I made a program as per your contents. Yes it
gets problem when i tried to add delete() and it gives
message nosuchMethodFound error. But when i used StringTokenizer
it can delete everything very nicely. Kindly see the following
program and test it. I deleted Bhubwan from "Hi Bhubwan Tewari"
String.
N.B. when you add delete( int start, int end) mehtod, make sure that you delete method along with parameters because there is no delete method without parameter inside StringBuffer class.

import java.util.*;
class STTest{
public static void main( String[] argv ){
String s="Hi Bhuwan Tewari";
StringTokenizer st=new StringTokenizer(s);
StringBuffer sb = new StringBuffer(30);

while(st.hasMoreTokens()) {

String sp=(st.nextToken());
sb.append(sp).append(" ");
System.out.println(sb);
}

System.out.println("This line we are getting after deleting from
pos 4 to pos 10 i.e. Bhuwan: ");
sb.delete(4,10);
System.out.println(sb);
}
}

Thanks,
Newaz
 
Brooks Duncan
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I am just guessing here, but check and make sure that the methods you want to use are not "new" as of Java 1.2. The JVM that ships with most browsesrs is surprisingly old, so unless you are using the Java Plug-In, you will have problems using recent additions to Java (I ran into this while trying to use methods of the Vector class).
-B
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic