Results 1 to 3 of 3
  1. #1
    jakaldama is offline Member
    Join Date
    Sep 2011
    Posts
    16
    Rep Power
    0

    Default Methods in Class String - moving input text to the end of the sentence

    How would I take the first word(the end is indicated by a space) that is inputted and move to the end of the string?

    Hey this is what i am typing
    this is what i am typing Hey

  2. #2
    JosAH's Avatar
    JosAH is offline Moderator
    Join Date
    Sep 2008
    Location
    Voorschoten, the Netherlands
    Posts
    13,458
    Blog Entries
    7
    Rep Power
    20

    Default Re: Methods in Class String - moving input text to the end of the sentence

    Quote Originally Posted by jakaldama View Post
    How would I take the first word(the end is indicated by a space) that is inputted and move to the end of the string?

    Hey this is what i am typing
    this is what i am typing Hey
    Find the position of that first space (look at the indexOf( ... ) method in the String class) and do what you have to do.

    kind regards,

    Jos
    cenosillicaphobia: the fear for an empty beer glass

  3. #3
    jakaldama is offline Member
    Join Date
    Sep 2011
    Posts
    16
    Rep Power
    0

    Default Re: Methods in Class String - moving input text to the end of the sentence

    eh.....

    public static void main(String[] args)
    {
    Scanner keyboard = new Scanner(System.in);
    String sentence;

    System.out.println("enter in a sentence please");
    sentence = keyboard.next();
    System.out.println(sentence);

    int position = sentence.indexOf(0);
    int whitespace = sentence.indexOf(" ");

Similar Threads

  1. enter a string sentence
    By amorosa19 in forum New To Java
    Replies: 13
    Last Post: 09-06-2013, 10:34 AM
  2. How to break down a sentence String?
    By Georgiafbi in forum New To Java
    Replies: 8
    Last Post: 02-07-2011, 03:00 AM
  3. Replies: 3
    Last Post: 11-09-2010, 12:10 AM
  4. Input output without string class
    By surenq1 in forum New To Java
    Replies: 4
    Last Post: 06-13-2010, 03:18 PM
  5. String/sentence to unicode convertion
    By sandeepvreddy in forum New To Java
    Replies: 5
    Last Post: 11-20-2008, 03:33 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •