• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Exception using split() method in java.lang.String

 
Uma Shwetha
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,
I get java.lang.NoSuchMethodError when using split(String) function in java.lang.String.
This is the code I used.
String str="1:2:3";
String arr[]=new String[10];
arr=str.split(":"); // gettting exception at this line
When I checked the syntax it seems to be exactly correct. Dont understand the reason for this error. Can anyone please help me out?
Thanks,
Uma.
 
Ernest Friedman-Hill
author and iconoclast
Marshal
Pie
Posts: 24208
35
Chrome Eclipse IDE Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,
Welcome to JavaRanch!
NoSuchMethodErrors happen when a method that was defined when you compiled your code isn't available when you run your code. This can happen when you compile with a newer JDK than you use at runtime.
The String.split() methods were introduced in JDK 1.4; so I imagine you're using a recent JDK to compile your code, and something older at runtime.
Either upgrade the runtime environment, or don't use the regexp stuff.
 
Uma Shwetha
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,
Thanks a lot for your reply.
You r right. I was having older version of JRE. I upgraded it. It worked.
Thanks,
Uma.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic