• 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 Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

String Operations

 
Greenhorn
Posts: 26
Firefox Browser Tomcat Server Chrome
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Everybody,


i have doubt from string operations. that is normally we can split string using some key words such as stringtokenizer and split functions. But now i want spliting string using general string concepts insteadof stringtokenizer and split keywords.



with regards,
sasikumar


thanks to advane
 
author and iconoclast
Posts: 24207
46
Mac OS X Eclipse IDE Chrome
  • Likes 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,

Welcome to CodeRanch!

I'm not quite sure what you might mean by "general string concepts", but perhaps you're thinking of regular expressions? Have a look at the java.util.regex.Pattern class to see if that will meet your needs.
 
ssasi kumar
Greenhorn
Posts: 26
Firefox Browser Tomcat Server Chrome
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
hi guys,
ok i will check java.regex package. but generally using java.regex package concept are understanding java experts only. so if you dont mind how do working normal string concepts using perform to stringtokenizer functions .
 
Ernest Friedman-Hill
author and iconoclast
Posts: 24207
46
Mac OS X Eclipse IDE Chrome
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

ssasi kumar wrote: normal string concepts.



Again, I have no idea what you mean by this. Maybe an example would help me?
 
Ranch Hand
Posts: 87
Opera Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Have a look at string functions like substring(..) , indexOf(..) , lastIndexOf(..) , charAt(..) etc.

For example , the below code will print 1.
 
Ranch Hand
Posts: 384
Spring Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
why not use toArray() ... if regex is not what you are looking for
 
Sheriff
Posts: 22783
131
Eclipse IDE Spring VI Editor Chrome Java Windows
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Because String does not have a toArray() method perhaps?
 
Lalit Mehra
Ranch Hand
Posts: 384
Spring Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Rob Spoor wrote:Because String does not have a toArray() method perhaps?



what about ... toCharArray() ...

i was just trying to put the logic up not the exact method name ...

anyways thanks Rob ...

 
Rob Spoor
Sheriff
Posts: 22783
131
Eclipse IDE Spring VI Editor Chrome Java Windows
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
toCharArray() should only be used if you really need a char[], because it creates a new char[]. If you only need to access characters from the String you should use length() and charAt(int) instead.
 
lowercase baba
Posts: 13089
67
Chrome Java Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

prem pillai wrote:Have a look at string functions like substring(..) , indexOf(..) , lastIndexOf(..) , charAt(..) etc.

For example , the below code will print 1.



What about this is unclear? What would you expect this to print? Why do you think this is wrong? We can't help you if you don't explain what you think the problem is.
 
prem pillai
Ranch Hand
Posts: 87
Opera Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

fred rosenberger wrote:
What about this is unclear? What would you expect this to print? Why do you think this is wrong? We can't help you if you don't explain what you think the problem is.



I am clear about what I have pasted in this thread .... but looks like you are not at all clear about "who is asking for help ?" & "what is he asking for ?"

The person who initiated this thread is asking for various ways to split a string without using Stringtokenizer or split() method etc

Anyways thanks for asking me so many questions

Peace
 
Marshal
Posts: 79177
377
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

ssasi kumar wrote: . . . split string using some key words such as stringtokenizer and split functions. . . .

Careful. Those aren't keywords.
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
reply
    Bookmark Topic Watch Topic
  • New Topic