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 / 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 |
Hi Friends, can you explain instance in java. In general instance means "occurence of something" . In java what is instance.
Which Math method is used to calculate the absolute value of a number?
Is list thread safe in java?
What is the final method?
Why should we create an object? what is a need of it? Apart from access members of a class i want what is a need of object what does it contain?? In normal class to access any member of thaht class we create object where as for static class we access its members using class name. what is a difference between them... thanks in advance.
What is passing parameters in java?
What are the important methods of java exception class?
Can a constructor be private and how are this() and super() method used with constructor?
0 Answers Flextronics, Hexaware,
How do I type unicode?
how to create multithreaded program? : Java thread
How to write custom exception in java?
How does the garbage collector works in java?