Dismiss Notice
Join Physics Forums Today!
The friendliest, high quality science and math community on the planet! Everyone who loves science is here!

Capitializing the java String?

  1. Dec 13, 2011 #1
    Like this is my program to change the words around in order. Like First two words go to the back. What I am having trouble is, How do I capitalize the first at the results section after
    the words order have changed??
    This is my program.

    import java.util. Scanner;

    public class Starwars{
    public static void main (String[]args){

    //Declare Variables Section
    int length, position=0;
    String phrase, phrase2, phrase3;
    Scanner input= new Scanner(System.in);

    //Obtain Input From Section
    System.out.println ("Enter your phrase: ");
    phrase= input.nextLine();
    length= phrase.length();
    System.out.println (phrase);

    //Perform Calculations Section
    int i=0;
    int i2=0;

    while (i<length){

    if (phrase.substring(i,i+1).equals(" ")){
    if (i2==2){





    System.out.println ("Yoda: " + phrase2 + ", " + phrase3);

  2. jcsd
  3. Dec 13, 2011 #2


    Staff: Mentor

    When you post code, please put [noparse]
    Code (Text):
    [/noparse] tags around it. I have done that for your code.
  4. Dec 13, 2011 #3
    But can you help me please?
  5. Dec 14, 2011 #4


    Staff: Mentor

Share this great discussion with others via Reddit, Google+, Twitter, or Facebook