i am trying to convert 1 string to integer.
using the command
int img=(int)Integer.valueOf(s4);
It works all fine in Java, as i tested it separately too.....
but in GWT it gives error saying
""Line 224: Cannot cast from Integer to int""
it is not able to typecast the integer to int :(
thne i tried just to assign the integer to int, like
"int entry = Integer.valueOf(s3);"
but then also its showing error saying that
"Line 196: Type mismatch: cannot convert from Integer to int "
can anyone tell me how to convert string to integer in GWT???
please help!!!!
thanking you
rakesh
is it there some special library in GWT which i need to include to get
an integer to int conversion???
please tell!!!
thank you veryy much!!!
it did worked!!!!
thanks alot!!!!
On Jul 8, 12:36 pm, "Ben Warren" <biggerbadder...@gmail.com> wrote:
> How about this:
>
> int img=Integer.valueOf(s4).intValue()
>
> regards,
> Ben
>
> On 7/8/07, konquerror <konquer...@gmail.com> wrote:
>
>
>
>
>
> > hiii
>
> > is it there some special library in GWT which i need to include to get
> > an integer to int conversion???
>
> > please tell!!!
>
> > On Jul 8, 8:45 am, konquerror <konquer...@gmail.com> wrote:
> > > Hii all
>
> > > i am trying to convert 1 string to integer.
>
> > > using the command
>
> > > int img=(int)Integer.valueOf(s4);
>
> > > It works all fine in Java, as i tested it separately too.....
>
> > > but in GWT it gives error saying
>
> > > ""Line 224: Cannot cast from Integer to int""
>
> > > it is not able to typecast the integer to int :(
>
> > > thne i tried just to assign the integer to int, like
> > > "int entry = Integer.valueOf(s3);"
>
> > > but then also its showing error saying that
> > > "Line 196: Type mismatch: cannot convert from Integer to int "
>
> > > can anyone tell me how to convert string to integer in GWT???
>
> > > please help!!!!
>
> > > thanking you
>
> > > rakesh- Hide quoted text -
>
> - Show quoted text -
int something = Integer.parseInt(s4);
What's going on is this: You need to configure your environment to use
Java 1.4 source mode, and NOT java 1.5 source mode, as GWT is not java
1.5 compatible.
int something = Integer.valueOf(s4); //this is correct in java 1.5,
but a type mismatch in java 1.4.
Integer.valueOf returns an Integer object. In java 1.5, Integer
objects are automatically 'unboxed' into ints, and ints are
automatically 'boxed' into Integer objects, whenever this seems
appropriate. Java 1.4 doesn't do this.
In Eclipse, check under the project settings, there's a place where
you can configure source compatibility. Set it to 1.4.
thank you very much for telling me the thing in quite detail.
You were correct
int something = Integer.parseInt(s4);
did worked.
can you help me by telling about some more things which doesnt work in
GWT??
I am doing a project over this, and i also have to find out what
features of JAVA can not be used while using GWT.
some of them i have came across, if you can tell me some then i cna
try and find out more about this.
thanking you.
rakesh
This method avoids any xtra casting cause it returns an int and not an
Integer
ddarby
It worked!!!!
yeah it does avoids casting and useful too.