Granny's Programming Pearls
"inside of every large program is a small program struggling to get out"
JavaRanch.com/granny.jsp
The moose likes Beginning Java and the fly likes String's  split() -- gives compilation error Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Java 8 in Action this week in the Java 8 forum!
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "String Watch "String New topic
Author

String's split() -- gives compilation error

kri shan
Ranch Hand

Joined: Apr 08, 2004
Posts: 1368
String[] result1 = "hai how".split("\\s");
for (int x=0; x<result1.length; x++)
System.out.println(result1[x]);

When i tried to compile this, i got the follwing error?
cannot resolve symbol
symbol : method split (java.lang.String)
location: class java.lang.String
String[] result1 = "hai how".split("\\s");
^
1 error
Abhinay Verma
Greenhorn

Joined: Dec 13, 2004
Posts: 24
It is working and not giving compilation errors.
The code gave the following output:
hai
how

Which version of J2SE are you using?
K Riaz
Ranch Hand

Joined: Jan 08, 2005
Posts: 375
Fine for me also. Do a "java -version".
Srinivasa Raghavan
Ranch Hand

Joined: Sep 28, 2004
Posts: 1228
String.split() is not in version 1.3. It's available only from V1.4


Thanks & regards, Srini
MCP, SCJP-1.4, NCFM (Financial Markets), Oracle 9i - SQL ( 1Z0-007 ), ITIL Certified
kri shan
Ranch Hand

Joined: Apr 08, 2004
Posts: 1368
Mine is jdk 1.3. What is the equivalent method in jdk 1.3?
Srinivasa Raghavan
Ranch Hand

Joined: Sep 28, 2004
Posts: 1228
You can use substring() and try to implement it.
K Riaz
Ranch Hand

Joined: Jan 08, 2005
Posts: 375
Or StringTokenizer.

Or upgrade.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: String's split() -- gives compilation error
 
Similar Threads
Cocoon compile build problem
"Cannot Resolve Symbols" Error
Compile error
Constructor Question
String.split?