Pls help me with strings

Pls help me with strings

To reverse a every other word in a string.

Example :- If the input is "This is a line of message" the output should be "sihT is a line fo message"

View Answers

July 18, 2011 at 1:31 PM

import java.util.*;
public class ReverseString{
    public static void main(String[]args){
        Scanner input=new Scanner(System.in);
        StringBuffer buffer=new StringBuffer();
        System.out.println("Enter string: ");
        String str=input.nextLine();
        StringTokenizer stk=new StringTokenizer(str);
        while(stk.hasMoreTokens()){
           String st=stk.nextToken();
           String reverse = new StringBuffer(st).reverse().toString();
           buffer.append(reverse);
           buffer.append(" ");
        }
        System.out.println("Reverse: " + buffer.toString());
    }
}

July 18, 2011 at 1:31 PM

import java.util.*;
public class ReverseString{
    public static void main(String[]args){
        Scanner input=new Scanner(System.in);
        StringBuffer buffer=new StringBuffer();
        System.out.println("Enter string: ");
        String str=input.nextLine();
        StringTokenizer stk=new StringTokenizer(str);
        while(stk.hasMoreTokens()){
           String st=stk.nextToken();
           String reverse = new StringBuffer(st).reverse().toString();
           buffer.append(reverse);
           buffer.append(" ");
        }
        System.out.println("Reverse: " + buffer.toString());
    }
}









Related Tutorials/Questions & Answers:
Pls help me with strings
Pls help me with strings  To reverse a every other word in a string. Example :- If the input is "This is a line of message" the output should be "sihT is a line fo message
Pls help me with strings
Pls help me with strings  To reverse a every other word in a string. Example :- If the input is "This is a line of message" the output should be "sihT is a line fo message
Advertisements
pls help me it urgent
pls help me it urgent  hey, pls help me i want to know that can we call java/.bat file from plsql/proceudre /trigger
pls help me it urgent
pls help me it urgent  hey, pls help me i want to know that can we call java/.bat file from plsql/proceudre /trigger
pls help me it urgent
pls help me it urgent  hey, pls help me i want to know that can we call java/.bat file from plsql/proceudre /trigger
pls help me with this question
pls help me with this question  how to write a program in C++ using encapsulation,polymorphism,inheritance and abstraction?(all these concepts should come in a single program
Pls help me...........
Pls help me...........  how to use the text file as input to insert the values injdbc?   Please visit the following link: Insert text file data into database
pls. help me - Java Beginners
pls. help me  please help me i do need now if its okay... Consider the method headings: void funcOne(int[] alpha, int size) int funcSum(int x,int y) void funcTwo(int[] alpha, int[] beta) and the declarations: int
pls help me sir its urgent
pls help me sir its urgent  thanks for reply, but i am getting this error pls help me its urgent type Exception report message description The server encountered an internal error () that prevented it from
i have a problem to do this question...pls help me..
i have a problem to do this question...pls help me..  Write a program that prompts the user to input an integer and the output the number with the digits reversed. For example if the input is 12345, the output should be 54321
pls help me!!!!!!!
do the combinations in java, pls help me its urhent - Development process
do the combinations in java, pls help me its urhent  import java.util.*; interface Expression { public void interpret(ArrayList exp); } class... one help me: action when condition1 and condition3 action when condition1
servlet not working properly ...pls help me out....its really urgent
servlet not working properly ...pls help me out....its really urgent  Hi, Below is the front page of my project 1)enty.jsp </form> </body> </html> </form> </body> </html>> <
Pls anyboby tell me...
Pls anyboby tell me...  which book easy to learn spring
help me
help me  hi sir pls tell me how to use ajax form validatin from very simple way with two ot three text field pls help me use ajax in php my email id is:- [email protected] pls sir give me some vasic information i know
hi , i cant make this programmer , can any one help me to make it pls - Java Beginners
hi , i cant make this programmer , can any one help me to make it pls  ... program. i cant find delete records or update records  pls can someone make this program for me
Hi.. how to write more than one sheets in a excel file... pls anybody help me....
Hi.. how to write more than one sheets in a excel file... pls anybody help me....  i can write only one sheet in a excel file.. but i want to write... go to second sheet... pls help me.. here my code.. import
help me
help me  pls... xplain dis code:- function go() { window.location.replace("logout.jsp",'window','toolbar=1,location=1,directories=1,status=1,menubar=1,scrollbars=1,resizable=1'); self.close
help me
help me  i have done as u directed but nothing happens gud to me..... . i am using netbeans is that matter at all help me and take me out from trouble where to store jfree api to use it for j2ee based project
help me
help me  HI. Please help me for doing project. i want to send control from one jsp page to 2 jsp pages... is it possible? if possible how to do
help me
help me  please send me the java code to count the number of similar words in given string and replace that word with new one
help me..
help me..   what are the component needed by grid computing, cloud computing and ubiquitous computing? discuss about the security of above computing. difference between that 3 computing
help me
help me  MY GLASSFISH SERVER NOT START PROPERLY help me warning shows DPL5404:Specification-Version for the optional package [ GNUJAXP ] in the jarfile [ C:\Program Files\Java\jdk1.7.0_02\jre\lib\ext\gnujaxp.jar
help me...
help me...  Write a program that inputs four words and them displays all possible permutations of the words. So, for example, if the words mad, dog, bites and man are entered, then the following are output : man bites mad dog
help me..
help me..  Write a program that inputs four words and them displays all possible permutations of the words. So, for example, if the words mad, dog, bites and man are entered, then the following are output : man bites mad dog mad
help me
button, and nationality I'm using dropdown list. Please help me. your kindness...help me  Hi I'm loges. I'm doing my final year project now, I have some problem in my project and i need some help on it. NowI'm doing a site
help me...
help me...  there is the picture given - cat - dog - rabbit - mouse a. create a class name b. create its attributes (at least 3 attributes) : species, size, leg c. create its methods ( at least 3 methods) : walk, eat, sleep
help me..
help me..  Design and write a class named Person and its two subclasses named Student and Employee. Make Lecturer and Admin subclasses of Employee. A person has a name, address, phone number and email address. A student has
help me
help me
help me
the order, Fourth button is Find length of text. and there are panels. Please help me...help me  Dear sir/medam i would like to know how to use the java string class method my programm have four button,(enter the text) that first
Help me
Help me  Hi, LWUIT is working in eclipse j2me for Symbian OS
help me
help me  how to print from a-z, A-Z with exact order using for loop? Thanks for all concern
Help Me
Help Me  What is the source code for Sample example for Mortgage Calculator in J2ME language for developing Symbian
Help me
Help me  plz i want code of program to add real numbers and magic numbers in java example this input :- 5+3i-2+3i output:- 3+6i
Help me
Help me  hello!!!!. i have a Excel file which includes 4 columns and somewhat 8500 rows.these rows i have printed in SQL thru Excel file and i have 1 MYSql database which includes all those 4 fields i have defined in excel file
help me
help me  I have a quastion a bout array whic is>>> 1-write aprogram to diplay a multiplication table for 1to 10 by entering the start number and the end number. EXAMPLE: ENTER START NUMBER:1 ENTER END NUMBER:3
help me
help me  Create a GUI application that allows a user to select a text file (using the JFileChooser). The program will then allow the user to do the following operations (selection of these operations must be made by clicking
Help me
Help me  HI I am using Tomcat6.0 this is the problem i got wen i run the code java.lang.NullPointerException org.apache.jsp.loginjsp.jspInit(login_jsp.java:23) org.apache.jasper.runtime.HttpJspBase.init
Help me
Help me  HI I am using Tomcat6.0 this is the problem i got wen i run the code , i am using login.html ,login .jsp,login.java and web.xml code java.lang.NullPointerException org.apache.jsp.loginjsp.jspInit(login_jsp.java:23
help me to do it in jsp
to insert and update the topics via admin page. pls help me to do...help me to do it in jsp  if we click on a topic it should direct to another page in separate window i need to create a part of the web page which
help me - WebSevices
help me   help me with the principals of designing agood websites and i can start
help me - WebSevices
help me   help me with the principals of designing agood websites and i can start
pls i need help with my assignment
pls i need help with my assignment  how to write a code that ask the user for the height of the triangle and prints the triangle using * eg if height is 3 it prints * and also using import java.util.Scanner
please help me.
please help me.  Please send me a code of template in opencms and its procedure.so i can implement the code. Thanks trinath
help me - JSP-Servlet
help me   how to open one compiled html file by clicking one button from jsp
Help me quickly plz??
Help me quickly plz??  Can you help me to write code quickly this code is a java code take input as double and should use command line arguments and enhanced for statement then find the combine of the numbers plz help quickly
please help me.
please help me.  How to read a properties file in java with a suitable example. Please send me. Thanks Trinath   Please visit the following link: Java read properties file
please help me.
please help me.  Please send me the validation of this below link. the link is http://www.roseindia.net/answers/viewqa/JSP-Servlet/9584-JSP-Servlet-Search-and-Edit.html Thanks Trinath
help me out...!!!!
help me out...!!!!  i have to make a project on console based application in java.. so can anyone guide me with some gd ideas that can be implemented
pls help its eating my time:(
pls help its eating my time:(  hi am new to struts2.0 in my application i have declared a list in static how to get the static list values in my result.jsp??? if i remove the static in the list the result is getting displayed.why

Ads