• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Liutauras Vilda
  • Devaka Cooray
  • Jeanne Boyarsky
  • Bear Bibeault
Sheriffs:
  • Junilu Lacar
  • Paul Clapham
  • Knute Snortum
Saloon Keepers:
  • Ron McLeod
  • Tim Moores
  • Stephan van Hulst
  • salvin francis
  • Carey Brown
Bartenders:
  • Tim Holloway
  • Frits Walraven
  • Ganesh Patekar

String's split() -- gives compilation error  RSS feed

 
Ranch Hand
Posts: 1490
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
 
Greenhorn
Posts: 24
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
It is working and not giving compilation errors.
The code gave the following output:
hai
how

Which version of J2SE are you using?
 
Ranch Hand
Posts: 375
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Fine for me also. Do a "java -version".
 
Ranch Hand
Posts: 1228
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
String.split() is not in version 1.3. It's available only from V1.4
 
kri shan
Ranch Hand
Posts: 1490
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Mine is jdk 1.3. What is the equivalent method in jdk 1.3?
 
Srinivasa Raghavan
Ranch Hand
Posts: 1228
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You can use substring() and try to implement it.
 
K Riaz
Ranch Hand
Posts: 375
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Or StringTokenizer.

Or upgrade.
 
All of the world's problems can be solved in a garden - Geoff Lawton. Tiny ad:
RavenDB is an Open Source NoSQL Database that’s fully transactional (ACID) across your database
https://coderanch.com/t/704633/RavenDB-Open-Source-NoSQL-Database
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!