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


Please Help Members By Posting Answers For Below Questions

Is map sorted in java?

562


What is the main purpose of serialization in java?

520


What is the do while loop syntax?

546


What modifiers may be used with an inner class that is a member of an outer class in java programming?

524


Is int primitive data type?

501






Describe string intern() methodology

586


What are data types in oop?

543


What is the multi-catch block in java?

526


What do you understand by abstract classes?

592


Difference between character constant and string constant in java ?

548


Where are variables stored?

546


What is the difference between preparedstatement and statement in java?

544


What is passing value java?

506


State the difference between strings and arrays.

593


How does arraylist work in java?

518