|
|
|
|
New Member
|
|
Oct 19, 2014, 10:17 PM
|
|
Java string program
Hii I please help me to make this string program I have to input "computer is fun" and output should be "is fun computer".
|
|
|
Adult Sexuality Expert
|
|
Oct 20, 2014, 07:29 AM
|
|
Look at String tokenization functions in the string library. What you can do with that is bust your string into tokens separated by a character, being white space in your case, and then you can do what you want with it. Is there a specific rule you have to use for this program?
|
|
|
New Member
|
|
Oct 20, 2014, 09:51 AM
|
|
Please help me in coding which string function we can use to manage these separate tokens in that order
|
|
|
Adult Sexuality Expert
|
|
Oct 20, 2014, 10:02 AM
|
|
What is the assignment? The answer changes based on this.
|
|
|
New Member
|
|
Oct 20, 2014, 10:05 AM
|
|
Thank you for your help but I'm looking for a program code for this explanation please help me in that I understand what you said but not able to convert it in program
|
|
|
Adult Sexuality Expert
|
|
Oct 20, 2014, 10:18 AM
|
|
The assignment specs tell me if you they want you to just juxtapose the first work last or if they want something more.
I am not going to post code. You have to write that yourself. There are several ways this could work, puesdo-code is:
// This will do what you want, but it will probably cause you to fail the assignment.
if( inputString == "Computer Is Fun")
systemPrint("Is Fun Computer");
//This could be a pass, but it isn't the most efficient way of doing it.
string firstWord;
string theRestOfIt;
bool haveFirstWord = false;
for(int I=0; I < inputString.Length; I++)
{
if(haveFirstWord)
theRestOfIt.append(inputString[i]);
else
firstWord.append(inputString[i]);
if(inputString[i] == ' ')
haveFirstWord = true;
}
systemPrint(theRestOfIt + firstWord);
// But wait, I googled the string class for Java.
string firstword = inputString;
firstword.replace(' ','\0'); // isolate the first word.
string theRestOfit = inputString.substring(firstword.length());
systemPrint(theRestOfIt + firstWord);
//------
Seriously, Google the Java string class, there is so much in there that can help you. It will all change if you need more versatility in your program as well.
|
|
|
New Member
|
|
Oct 20, 2014, 10:21 AM
|
|
Thank you for your kind help that will definitely help me
|
|
|
New Member
|
|
Oct 25, 2014, 12:03 AM
|
|
Error message
Originally Posted by getvik_333
Thank you for your kind help that will definitely help me
I have tried above program and when I am compiling it I am getting an error "array riquired but java.string.lang found" please help me rectifying this error
|
|
Question Tools |
Search this Question |
|
|
Add your answer here.
Check out some similar questions!
Java string concatenation in the iteration
[ 1 Answers ]
Hi everyone can any help me with this:
Make a program that asks for an integer and prints all integers from one to the entered integer. By performing a string concatenation in the iteration, let the label text value to be the value it had last lap plus the new century.
Thanks to everyone...
How to store Scanner data in string in java?
[ 0 Answers ]
I am new to java, currently I am working on a program regarding networking.
My program compiles without error.
I have placed 3 checks in my program. It passes through check 1 but does not reach 2.
I want string player2msg to store whatever data comes from scanner fromServer.
I expected...
Having difficulty with Java String
[ 1 Answers ]
Can someone please me how I can write a Java code to transform the quantity 6 As into the string AAAAAA. I'm trying this, but it does not work:
public class Letters {
public static void main (String args) {
String words=" ";
String numberofwords="A";
int wordcount=6;
Java netbeans program- Connection between java and mysql,How to conn
[ 0 Answers ]
which I wrote from a book but when I run it, it shows exception
please give me the code to connect jlistbox to database when I click on btn1.
btn coding should search "name" in database and shows all the names in listbox
my coding:
here-- r1,r2,r3 are radio btns and l1,l2,l3 are labels,...
View more questions
Search
|