Author of ExamLab - a free SCJP / OCPJP exam simulator
What would SCJP exam questions look like? -- OCPJP Online Training -- Twitter -- How to Ask a Question
There are only two hard things in computer science: cache invalidation, naming things, and off-by-one errors
Some problems are so complex that you have to be highly intelligent and well informed just to be undecided about them. - Laurence J. Peter
There are only two hard things in computer science: cache invalidation, naming things, and off-by-one errors
SCJP 1.4 - SCJP 6 - SCWCD 5 - OCEEJBD 6 - OCEJPAD 6
How To Ask Questions How To Answer Questions
adeeb alexander wrote:I have even done what Garrett has said, i used the split() method to split with comma. Just like this str.split(",") but the problem here is after i split i get two string the first is: ferrari car and the second is: apple fruit. Now when i use trim() method, because i need the spaces between ferrari car this doesnt suit my requirement, the trim() method remove all the spaces including which i need
public String trim()
Returns a copy of the string, with leading and trailing whitespace omitted.
If this String object represents an empty character sequence, or the first and last characters of character sequence represented by this String object both have codes greater than '\u0020' (the space character), then a reference to this String object is returned.
Otherwise, if there is no character with a code greater than '\u0020' in the string, then a new String object representing an empty string is created and returned.
Some problems are so complex that you have to be highly intelligent and well informed just to be undecided about them. - Laurence J. Peter
Now the problem is that i get a different output if i dont give any space between word and comma.
Some problems are so complex that you have to be highly intelligent and well informed just to be undecided about them. - Laurence J. Peter
I am getting 1 error i.e 'cannot find symbol method split(java.lang.String)'. Please help me out
adeeb alexander wrote:Thanks for your reply Garrett.
Can you please tell me where i am going wrong now. I am getting 1 error i.e 'cannot find symbol method split(java.lang.String)'. Please help me out
>
Some problems are so complex that you have to be highly intelligent and well informed just to be undecided about them. - Laurence J. Peter
>
Value in B: porsche car
Value in C: porsche
Value in C: car
Value in B: ferrari car
Value in C:
Value in C: ferrari
Value in C: car
Value in B: yamaha bike
Value in C:
Value in C: yamaha
Value in C: bike
Press any key to continue...
Some problems are so complex that you have to be highly intelligent and well informed just to be undecided about them. - Laurence J. Peter
Did you see how Paul cut 87% off of his electric heat bill with 82 watts of micro heaters? |