|
|
|||||||||
|
|||||||||
|
|||||||||
| |
|||
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Display Modes |
|
#1
|
|||
|
|||
|
Hello, i got a question for you java programers about if it's possible to change some text eg. katt = "help me"; to end up like: "help-me";
Is there any known way to change the " " to "-" automaticly? thanks, nait |
|
#2
|
|||
|
|||
|
In answer to the specific question the following code should help you out.
Code:
String blah = new String ("help me");
blah = blah.replace (' ', '-');
To clear up an obvious problem related to this please note that - Code:
String blah = new String ("help me");
blah.replace (' ', '-');
does not work since strings are immutable, ie cannot be changed. So you can set a string equal to the return value of a function but cannot directly change a string via one of its methods. If you don't get this give it a try and see what happens. And for more general help, queries like this are best directed to the java api http://java.sun.com/j2se/1.4.2/docs/api/ which will answer so many questions for you and to get anywhere with java you will have to get used to trawling through this lovely document .Hope this helps, -KM- |
|
#3
|
|||
|
|||
|
Thanks alot mate!
|
![]() |
| Viewing: Dev Articles Community Forums > Programming > Java Development > a java beginner needs some help |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|