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 |
is it mandatory to deaclare all variables public static fianl in interfaces?if i declare like in the below program, public interface A { public static final int I=0; int j=0; } in interface A,what is the difference between I,j?
why we r not use pointers in corejava?
what is the difference between multitasking and multithreading?
What is passed by reference and pass by value ?
Can a lock be acquired on a class in java programming?
What is concurrent hashmap and its features?
Is singleton class immutable?
What is rmi and steps involved in developing an rmi object?
What does the “static” keyword mean?
Define a java class.
Is singleton a bad practice?
program to find 25 square = 625 here the 625 of last two digits is equal to 25, i don't know excatly what this type of number is called