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
What is the difference between multiple processes and multiple threads?
What is dot operator?
What are the main features of java?
what is the messsage u r going to get from an objectoriented programing?
What is equals method in java?
What is the += operator called?
What is comparator in java?
Can anonymous class have constructor?
What is dynamic binding(late binding)?
How thread scheduler schedule the task?
Why main function is static?
What happens when heap memory is full?
When we serialize an object does the serialization mechanism saves its references too?
What is the difference between a switch statement and an if statement?
explain the difference between jdk and jvm?