• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

convert a string into character array

 
naved momin
Ranch Hand
Posts: 692
Eclipse IDE Java Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
can any one convert a string into character array without even calling a single library function
its a challenge question, lets see how experts solve this problem ?
@rob,@jeff,@champbell.....
 
Mohamed Sanaulla
Saloon Keeper
Posts: 3159
33
Google App Engine Java Ruby
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I am no expert and I dont know the idea behind this question. One way I could think of is to use getBytes on string and then cast each of the bytes into a char. (Not sure how this would work for multibyte characters). I wouldn't really think too much about such questions because in a industry no one would expect you to write everything from scratch. APIs are meant for reuse and not to reinvent the wheel.
 
Roberto Perillo
Bartender
Posts: 2271
3
Eclipse IDE Java Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
naved momin wrote:...without even calling a single library function


What would be a "library function"? You mean, methods out of the Java API? Or any method (including methods of the Java API)?
 
Campbell Ritchie
Sheriff
Pie
Posts: 49367
62
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
naved momin wrote: . . . its a challenge question, . . .
Sounds like a party trick which ought to go to Diversions.
@rob,@jeff,@champbell.....
Unwharranted flatthery whill geth yhou nowhhere
 
naved momin
Ranch Hand
Posts: 692
Eclipse IDE Java Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Campbell Ritchie wrote:
naved momin wrote: . . . its a challenge question, . . .
Sounds like a party trick which ought to go to Diversions.
@rob,@jeff,@champbell.....
Unwharranted flatthery whill geth yhou nowhhere

don't get me wrong guys i know, API is meant for reuse and there is no point in reinventing the wheels, but at least we should now how the invention happens, don't you think so ?
@campbell sorry, i m not a spell bee so most of the time i end up with spelling mistakes, hope you don't mind, but i literally make sure that people understands my question
Note: if any one is thinking that i m doubting on any of your's abilities then this is certainly not true, all i want is, is there a way to do this kind of thing,
and i now no one ask this kind of question , but i don't ask questions which interviewer ask, because i m not a job hunger, all i want is knowledge, so whatever questions i ask here or in any forums
whether questions are foolish or meaning full it is straight from my mind ......hope you understand :-|
 
Jesper de Jong
Java Cowboy
Saloon Keeper
Posts: 15354
39
Android IntelliJ IDE Java Scala Spring
  • Likes 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
naved momin wrote:can any one convert a string into character array without even calling a single library function

Without any method from the standard Java API? No, that's not possible. Or do you just mean: without calling any methods in the String class? If it's the latter, then you could use reflection to get at the internals of the string.
 
Mohamed Sanaulla
Saloon Keeper
Posts: 3159
33
Google App Engine Java Ruby
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Jesper de Jong wrote:
naved momin wrote:can any one convert a string into character array without even calling a single library function

Without any method from the standard Java API? No, that's not possible. Or do you just mean: without calling any methods in the String class? If it's the latter, then you could use reflection to get at the internals of the string.


This is where I was thinking that the API would be used- at least to get the contents of the String.
 
Jeff Verdegan
Bartender
Posts: 6109
6
Android IntelliJ IDE Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
naved momin wrote:can any one convert a string into character array without even calling a single library function


Not possible.
 
Campbell Ritchie
Sheriff
Pie
Posts: 49367
62
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
naved momin wrote: . . . i m not a spell bee so most of the time i end up with spelling mistakes, . . .
. . . and I can wind you up about them! Mwaahaahaahaahaa
 
naved momin
Ranch Hand
Posts: 692
Eclipse IDE Java Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Campbell Ritchie wrote:
naved momin wrote: . . . i m not a spell bee so most of the time i end up with spelling mistakes, . . .
. . . and I can wind you up about them! Mwaahaahaahaahaa

so the conclusion is "no" in one word ? .....thanks for your time and comments ...
 
Campbell Ritchie
Sheriff
Pie
Posts: 49367
62
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
And there we were, thinking you had found some magic trick and would show us it when we were all stumped!
 
Praveen Kumar M K
Ranch Hand
Posts: 256
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
LOL! Did I just get Trolled!
 
Campbell Ritchie
Sheriff
Pie
Posts: 49367
62
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Praveen Kumar M K wrote:LOL! Did I just get Trolled!
Bad luck, no you didn’t.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic