How to reverse words in a sentence without using array or split or string tokenizer in Java?

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 (78) [earned 5 cycles]
View Answer
vedprad1 (831)

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


@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 (78)

@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.


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