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 |
What is java developer skills?
what is synchronization
What is nested loop? What is dangling else condition in it?
What is difference between identifier and variable?
Explain runtime exceptions?
What is the use of static keyword in "public static void main()"
10 Answers College School Exams Tests, Infosys, Six Dee Telecom,
hoe can u call a constructor of a private classs to other inherited claa??
Explain the key functions of data binding?
0 Answers Akamai Technologies, Aspire, Impetus, Infogain, Tavant Technologies, Virtusa,
What is the purpose of static keyword in java?
Which variable is the independent variable?
Why there are some null interface in java? What does it mean?
What does it mean to be immutable?