How to reverse words in a sentence without using array or split or string tokenizer in Java?
h
SolarBoom (71)

how to reverse words in a sentence without using split orarray or string tokenizer.
I/p :- how are you
O/p :- you are how

You are viewing a single comment. View All
Answered by Edgod (58) [earned 5 cycles]
View Answer
vedprad1 (694)

Why wouldn't you want to use split()? It is way more efficient.

SolarBoom (71)

@vedprad1 Split() makes things easier. But our efficiency comes when we are not dependent on the functions which are not the most important function of the stings.

Edgod (58)

@SolarBoom That doesn't make sense, unless I'm misunderstanding you. The split() method exists so that programmers wouldn't have to reinvent the wheel, which makes Java more efficient. It's just a function. The answer I gave you above is me literally redoing split() in a different way. I thought you asked the question because you were curious.

SolarBoom (71)

@Edgod That's true too. I was actually curious