Share on Google+Share on Google+

Java Beginner
1 Answer(s)      5 years and 9 months ago
Posted in : Java Beginners

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 2:01 PM

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

Related Tutorials/Questions & Answers:
java beginner
java beginner  hai a i'm beginner 2 java... i want to fetch data from database using combo box(drop down list) without using javascript...when i click list(ex:countrys should b selected)selected country should get inserted
Java Beginner
Java Beginner  can we declare a class inside an interface? where this type of declaration required? give one example
java beginner
java beginner  Hi i have a methd that is public static insert ( map p), i have passed a java map object in this method , so i want to store employee infrmation in haspmap and how to find highest salery and afetr public
java beginner
java beginner  Hi using hashcode() and equal() method and hashmap object how to compare employee lastname and firstname ,display in console
Java Beginner
Java Beginner  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
java beginner
java beginner  Hi how to sort list of element containing a data object like date of birth of employee. display employee in youngest first and oldest last , using one of the collection class for sorting
java beginner
java beginner  Write a program that will grade the students quiz. The program will ask the user to enter the number of the questions in the quiz, the right answer for each question and save it in array. The program will ask
java beginner
java beginner  HI I am swetha iam confused when to use service(), doget(), dopost() method in servlets   Any request from client are handled initially by the service() method before delegating to the doXxx() methods
jAVA BEGINNER PROBLEMS  I need the program that takes from standard input an expression without left parenthesis and prints the equivalent infix expression with the parenthesis inserted??? Like EXAMPLE: 1+2)3-4)5-6
Java beginner - Java Beginners
Java beginner  what is the diffrence between abstraction and interface? with coding
Beginner  how to call a gui class from applet class   Hello Friend, Please visit the following link: Thanks
beginner  provide a simple java exception program that uses try , catch, throw and finally blocks
Tutorial for total beginner in Java
Tutorial for total beginner in Java - Explains the Basics of Java programming language. This is a video tutorial for total beginner in Java. In this video... language. This video is for total beginner in Java which will teach how to create
How a beginner can start Java Programming?
How a beginner can start Java Programming?  I Just have programming knowledge of C & C++. Let's know how I can learn Java? Is there any Java... have programming language of C and C++ then you can learn Java programming
Nag(Beginner)  sir i am new to java.. i want to know what topics comes under core java, adv. java and also the remaining topics... plz tell me   Java Tutorials
Generating Random Numbers to Fill array. Java Beginner needing help!
Generating Random Numbers to Fill array. Java Beginner needing help!  Hello all! I am new to this site, and Java programming. My problem is: Write...() methods. I am new to Java programming and this seems mind blowing to me :( I
Learn Java for beginner
more. One way to learn Java is through online training. Here a beginner in Java...Java is the most used programming language in the world. Java provides... and available to anyone. This is the advantage Java has on other language
Java guide
Java guide       Any beginner requires guidance to start with. A beginner in the field of java... practical guide to the beginner and experienced java programmer. These tutorials have
Servlet Tutorial for beginner
Servlet Tutorial for beginner  Hi, I am beginner in Servlet. I have learned the JSP a little bit. Now I wan't to learn Servlet. Tell me the URL... developed in Java. Servlet's run on Servlet container. Read more at Servlet
Hibernate programming tutorial for beginner
Hibernate programming tutorial for beginner  Hi, I am beginner in Hibernate and I wish to learn it quickly. I am hoping to learn the latest ORM... the link: Hibernate beginner tutorial. This link contains many tutorials
Java Tutorial
Java Tutorials If you are a beginner and looking for the Java tutorials to learn java programming language from scratch then this the best place to start with the Java programming language. Java programming language contains huge
SQL for Beginner
SQL for Beginner      ... the easiest elaborative examples for the beginner. The beginner will reached into the immediate result as the SQL command is submitted. It bring the beginner
Java Spring Hibernate Struts Training Retrieve database from the table dynamically in jsp from oracle using servlet What does core Java include? java What are some way to learn Java quickly? Is it required to learn Java before learning Java Script? Is it necessary to learn java script before learning PHP? Are HTML5 and Java Script boosts Java career? Is Java object oriented? Fingerprint application with Java Uninstall Oracle Virtual Box JSON to HashMap Free Java online Training I want example of Control Statement in Java ANSI Color Codes with Python Create a Program that Calculates Input What is difference between JDK,JRE and JVM? How to see ubuntu version on server? How to get Page Source in Selenium (WebDriver) using Java? The path to the driver executable must be set by the webdriver.gecko.driver system property parse data from a link in java Java Program Qns using BlueJ How to fix HAX Kernel Module Is Not Installed error? Installing Audacity Looking for code Logic to check track changes & Coments in MSWord, MSWordx, MSExcel, MSExcelx is ON/OFF Installing JDK on Mac SAX Parser exception ERROR 601 (42P00): Syntax error. Encountered Thread java.lang.NoClassDefFoundError: org/apache/commons/fileupload/FileItemFactory How to install Ubuntu 16.04 LTS? HttpServletRequest cannot be resolved to a type in eclipse - Solved Unhandled event loop exception GC overhead limit exceeded Spring Data jpa with apache phoenix Caused by: java.lang.IllegalArgumentException: Not a host:port pair: PBUF o.a.h.h.z.RecoverableZooKeeper - Possibly transient ZooKeeper, quorum= com.thinkaurelius.titan.diskstorage.hbase.HBaseStoreManager class not found com.thinkaurelius.titan.diskstorage.hbase.HBaseStoreManager not found How to download and install Java 8 on Windows? How to uninstall JDK 7? How to install gtk-doc-tools package in Ubuntu? How to install Oracle JDK 8 on Ubuntu? ejabberd_ctl.beam not found - Solved How to convert date to UTC format in Java? How to install autoconf, automake and libtool in Ubuntu 15.10? How to convert current date to mm dd yyyy format in Java? How to convert current date to dd mm yyyy format in Java? How to stop window closing in "internalFrameClosing" event. How to find list of all index in Neo4j? file location SASLError using PLAIN: not-authorized


Advertisement null