Welcome to the Java Programming Forums


The professional, friendly Java community. 21,500 members and growing!


The Java Programming Forums are a community of Java programmers from all around the World. Our members have a wide range of skills and they all have one thing in common: A passion to learn and code Java. We invite beginner Java programmers right through to Java professionals to post here and share your knowledge. Become a part of the community, help others, expand your knowledge of Java and enjoy talking with like minded people. Registration is quick and best of all free. We look forward to meeting you.


>> REGISTER NOW TO START POSTING


Members have full access to the forums. Advertisements are removed for registered users.

Results 1 to 2 of 2

Thread: Need suggestion to write a program

  1. #1
    Member
    Join Date
    Mar 2011
    Posts
    114
    Thanks
    6
    Thanked 0 Times in 0 Posts

    Default Need suggestion to write a program

    There is string "aaa bbb cccc eee dddd ffff gggg sss qqq ertdfg"
    We have to write a program to swap the alternate values in above string i.e. o/p has to be
    "bbb aaa eee cccc ffff dddd sss gggg qqq ertdfg"


  2. #2
    Super Moderator pbrockway2's Avatar
    Join Date
    Jan 2012
    Posts
    987
    Thanks
    6
    Thanked 206 Times in 182 Posts

    Default Re: Need suggestion to write a program

    How do know - and how did you figure out - that swapping the elements of "aaa bbb cccc eee dddd ffff gggg sss qqq ertdfg" yields "bbb aaa eee cccc ffff dddd sss gggg qqq ertdfg"?

    Before you write any code you should have a plan of attack: you should be conscious of the steps involved in how you solved the problem in this case, and be able to describe them. These steps - simple but comprehensive - will form the basis of your code.

    Look through the String API documentation for methods that will help with splitting a string into its words. If you get stuck describe your approach. And post your code! Whether it works or not (it won't to begin with) it is the starting point.

Similar Threads

  1. Help me write this program.
    By HuKjr in forum What's Wrong With My Code?
    Replies: 4
    Last Post: December 6th, 2011, 11:05 AM
  2. How would I write this program?
    By mjballa in forum Java Theory & Questions
    Replies: 2
    Last Post: November 14th, 2011, 11:49 PM
  3. help me write java program
    By stevisto in forum Member Introductions
    Replies: 1
    Last Post: September 13th, 2011, 03:44 PM
  4. how can i write this program
    By lavudyagopi27 in forum Java Theory & Questions
    Replies: 2
    Last Post: September 17th, 2010, 08:11 AM
  5. Someone please help me write a simple program!!!
    By ocean123 in forum Loops & Control Statements
    Replies: 3
    Last Post: June 14th, 2009, 09:46 PM