[XoL]
2012-09-10 21:38:28
Hey guys, sorry I have a question I can't seem to figure this out…
I have to: Write a program that will read a line of text as input and then display the line with the first word moved to the end of the line.

This is what I did so far, kind of >.< there was a lot of googling lol.
Anyway please help me figure it out, in the dumbest way possible :p (I don't know any of the library functions) Also please keep using JOptionPane
I have to: Write a program that will read a line of text as input and then display the line with the first word moved to the end of the line.

This is what I did so far, kind of >.< there was a lot of googling lol.
import javax.swing.JOptionPane;
public class FirstToBack2
{
public static void main(String[] args)
{
String theWord = JOptionPane.showInputDialog("Enter the Words: ");
JOptionPane.showMessageDialog(null,theWord);
int space = theWord.indexOf(' ');
String firstWord = theWord.substring(0, space);
JOptionPane.showMessageDialog(null, firstWord);
JOptionPane.showMessageDialog(null, theWord + firstWord);
}
}
Anyway please help me figure it out, in the dumbest way possible :p (I don't know any of the library functions) Also please keep using JOptionPane