How to Convert a String object to Int or integer?
I have a string likeString str = "abc";now i wanna convert this str to Integer or int..i dont wanna convert this to character array or something else...anybody help me out..
[194 byte] By [
AkilaCa] at [2007-11-26 22:30:54]

> I have a string like> String str = "abc";What value would abc represent? Is it hex or a number in another base?Take a look at Integer.parseInt(String s, int radix) Kaj
kajbja at 2007-7-10 11:36:05 >

So into what integer value should "abc" be converted ?
You might check [url=http://java.sun.com/j2se/1.5.0/docs/api/java/lang/String.html#hashCode()]String.hashCode()[/url] or [url=http://java.sun.com/j2se/1.5.0/docs/api/java/lang/Integer.html#parseInt(java.lang.String, int)]Integer.parseInt(String s, int radix)[/url].
yes..thanks, but is it possible to reconvert the same int or integer value to the string..for eg..if i convert a string "str" to some int value say i..is it possible to get the string "abc" from value i?
yes..thanks, but is it possible to reconvert the same int or integer value to the string..for eg..if i convert a string "str" to some int value say i..is it possible to get the string "abc" from value i?
I'm afraid there are more possible Strings than possible integer values. So, I would say no, this is not possible.
Oh..no..Actually my problem is that, i have to pass "#" symbol for one of the values in query parameter.. while passing so, after this parameter none of the other parameters are considered..how to handle this? any idea?
> Oh..no..Actually my problem is that, i have to pass> "#" symbol for one of the values in query parameter..> while passing so, after this parameter none of the> other parameters are considered..how to handle> this? any idea?Eh, what?
kajbja at 2007-7-10 11:36:05 >

I am sending a request that contains multiple request parameters.
for one of the parameters iam sending a value as "#". if i send so, other parameters are not considered.
for eg..
http://localhost:8080/cs?query=#&name="me" -- if i send like this, name parameter is not considered..since # represents the current page.. got my problem?
I'm not a web developer, but I think you should encode the url. # will become %23Kaj
kajbja at 2007-7-10 11:36:05 >

yes u r rite..but iam not sending the request as part of url..hence the prob...
Why do you need to change a String object to int if you just need to check whether it is "#" or not ?or they are 2 unrelated questions ?
rym82a at 2007-7-10 11:36:05 >

yes those r related..first i thought of checking whether its "#" as you said. i doubted whether someother special character will affect in same way..so thought of converting the parameter value(such as "#'' or "abc") to ASCII value and send the same as request parameter..
TryString encoded = java.net.URLEncoder.encode("abc#def", "UTF-8");
It works fine..i think we can avoid the encoding type, rite?just single parameter encode() method should work fine.
> It works fine..i think we can avoid the encoding> type, rite?No
kajbja at 2007-7-21 18:47:03 >

why should not?by default IE, takes encoding type as "UTF-8"na?
> why should not?> > by default IE, takes encoding type as "UTF-8"na?Read about what the argument represents.Kaj
kajbja at 2007-7-21 18:47:03 >
