if we give input as " hi how are you" then the output
should be "uoy woh"...it should skip odd words in the input
and should reverse even words from the end of string...can
anyone help me to write this program in java
Answer Posted / nagesh
package test;
public class TestClass {
/**
* @param args
*/
public static void main(String[] args) {
// TODO Auto-generated method stub
StringBuffer sb = new StringBuffer("hi how
are you");
String input = sb.reverse().toString();
String output = "";
String[] stInput =input.split(" ");
for(int i=0;i<stInput.length;i++)
{
if(i%2==0)
{
if(i==0)
{
output = stInput[i];
}
else
{
output = output + " "+
stInput[i];
}
}
}
System.out.println("Output String is =="+output);
}
}
| Is This Answer Correct ? | 6 Yes | 0 No |
Post New Answer View All Answers
How many types of the indexof method are there for strings?
Why does java not support pointers?
What does java edition mean?
What does percent mean in java?
describe synchronization in respect to multithreading? : Java thread
What is the use of arrays tostring () in java?
What is OOP's Terms with explanation?
How do you check if an arraylist is not empty?
Where can I find jdk in my computer?
I want my class to be developed in such a way that no other class (even derived class) can create its objects. Define how can I do so?
What is style and indentation?
What is prime number in java?
What are the 6 mandatory procedures for iso 9001?
What is nextint java?
What is return data type?