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]
# 1
> 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 > top of Java-index,Java Essentials,Java Programming...
# 2

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].

TimTheEnchantora at 2007-7-10 11:36:05 > top of Java-index,Java Essentials,Java Programming...
# 3
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?
AkilaCa at 2007-7-10 11:36:05 > top of Java-index,Java Essentials,Java Programming...
# 4
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?
AkilaCa at 2007-7-10 11:36:05 > top of Java-index,Java Essentials,Java Programming...
# 5
I'm afraid there are more possible Strings than possible integer values. So, I would say no, this is not possible.
TimTheEnchantora at 2007-7-10 11:36:05 > top of Java-index,Java Essentials,Java Programming...
# 6
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?
AkilaCa at 2007-7-10 11:36:05 > top of Java-index,Java Essentials,Java Programming...
# 7
> 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 > top of Java-index,Java Essentials,Java Programming...
# 8

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?

AkilaCa at 2007-7-10 11:36:05 > top of Java-index,Java Essentials,Java Programming...
# 9
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 > top of Java-index,Java Essentials,Java Programming...
# 10
yes u r rite..but iam not sending the request as part of url..hence the prob...
AkilaCa at 2007-7-10 11:36:05 > top of Java-index,Java Essentials,Java Programming...
# 11
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 > top of Java-index,Java Essentials,Java Programming...
# 12
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..
AkilaCa at 2007-7-10 11:36:05 > top of Java-index,Java Essentials,Java Programming...
# 13
TryString encoded = java.net.URLEncoder.encode("abc#def", "UTF-8");
jsalonena at 2007-7-10 11:36:05 > top of Java-index,Java Essentials,Java Programming...
# 14
It works fine..i think we can avoid the encoding type, rite?just single parameter encode() method should work fine.
AkilaCa at 2007-7-10 11:36:05 > top of Java-index,Java Essentials,Java Programming...
# 15
> It works fine..i think we can avoid the encoding> type, rite?No
kajbja at 2007-7-21 18:47:03 > top of Java-index,Java Essentials,Java Programming...
# 16
why should not?by default IE, takes encoding type as "UTF-8"na?
AkilaCa at 2007-7-21 18:47:03 > top of Java-index,Java Essentials,Java Programming...
# 17
> 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 > top of Java-index,Java Essentials,Java Programming...