Campbell Ritchie wrote:I find it difficult to understand your question. You would appear to want to run the if and the else, combining their “output”. You would do well to play with replaceAll, and see what happens when you do and do not have R1 inside the String. I suspect the if-else is unnecessary.
You might do well to investigate Maps; R1 = bus/train looks like something a Map is very good at implementing.
R. Jain wrote:
deepika deepi wrote:size of the array is 15.
In which case, you are not getting your code..
Try to print the array obtained as you split your keyword.. Also print its length..
deepika deepi wrote:
keywordsplit[0] contain output: located serve chief
keywordsplit[1] contain output: reserve biosphere star
keywordsplit[2] contain output is not displayed
No they don't.. Try printing array and see what you get..
Christophe Verré wrote:Just in case, when I said that you may prefer using StringBuilder, I didn't mean that this would fix your problem. Creating a new StringBuilder in a loop will still erase all previous content.
John Jai wrote:Post your changed code for further assistance.
Christophe Verré wrote:Creating a new StringBuffer in a loop will obviously erase all previous content. (by the way, you may prefer using StringBuilder).
R. Jain wrote:
What will be size of array generated when you use the above split code??
Winston Gutkowski wrote:
deepika deepi wrote:code is:
No it isn't; because that code could not possibly produce the output you say it does.
i hope i am making it easier now. I have given all the datas. Help me.
As I said before, EaseUp. Simply repeating "Help me" isn't going to get the job done any quicker.
Read the HowToAskQuestionsOnJavaRanch page; and also this one and this one.
And when you've done that, come back and explain your problem, NOT your solution.
Winston
R. Jain wrote:
deepika deepi wrote:
Yor telling to use like this
String[] input = sentence.split("\t");
String integer = input[0];
String integer1 = input[1];
String keyword = input[2];
String rule = input[3];
String[] keywordsplit = keyword.split(",");
String integer = keywordsplit[0];
String integer1 =keywordsplit[1];
Yes.. you did it right.. Check the duplicate names in variable declaration..
Winston Gutkowski wrote:
deepika deepi wrote:ya they are keywordsplit[0] and keywordsplit[1] will be words
Right, so don't put them in fields called 'integer...'. It's confusing.
Winston