hi all ,
i want to make function that remove any space before sentance
(i.e if user enter multi space before your comment remove it )
and if enter multi space only this function return empty string .
hi all ,
i want to make function that remove any space before sentance
(i.e if user enter multi space before your comment remove it )
and if enter multi space only this function return empty string .
good luck with that... once you've written some code, don't get the result you want and don't know where the problem lies, just submit your code and the error you get.
but, like you said it: YOU want to make that function
need some pointers? an easy way to do it is using a very simple String object in which you store your text, and using the indexof() and substring() methods.
thanks ,
my function worked correct wher i make that
String str = " amtallah ";
String trimmedStr = str.trim()
What the prvious poster was saying is, post the method you are using, as well as the code where you get the string from the user, and where you then call the method involved.
So you solved your issue or you still have a question? You haven't actually made a function there - just used an existing String function, but perhaps that is all you needed to do?
Note that if you are trimming input from a text box, you will want to first make sure that the string is not null as well
String inStr = aTextField.getText();
if (inStr != null)
inStr = inStr.trim();
We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.