The Artima Developer Community
Sponsored Link

Java Answers Forum
how..?

4 replies on 1 page. Most recent reply: Oct 27, 2002 7:28 AM by Nimesh

Welcome Guest
  Sign In

Go back to the topic listing  Back to Topic List Click to reply to this topic  Reply to this Topic Click to search messages in this forum  Search Forum Click for a threaded view of the topic  Threaded View   
Previous Topic   Next Topic
Flat View: This topic has 4 replies on 1 page
ravikumar

Posts: 10
Nickname: ji
Registered: Oct, 2002

how..? Posted: Oct 24, 2002 2:49 PM
Reply to this message Reply
Advertisement
hi,
i want to display variables (integers and floats) in an applet....i know drawString can only write String things....how to display normal numbers? ...


Kishori Sharan

Posts: 211
Nickname: kishori
Registered: Feb, 2002

Re: how..? Posted: Oct 24, 2002 5:27 PM
Reply to this message Reply
Don't go in details and whenever you need a string out of number just write:
your_nuber + ""

For example,
int i = 289;
String str = i + "" ;
Now your i value 289 is in String str. In drawString method
g.drawString ( i + "", your_other_parameters ) ;
Now drawString will draw the value 289.

I am just giving you examples of converting a number to string and any details on any methods or anything else...
To be a purist, you can use String.valueOf ( i ) to get the string out of i.

Thanks
Kishori

Nimesh

Posts: 7
Nickname: nm
Registered: Oct, 2002

Re: how..? Posted: Oct 25, 2002 6:55 AM
Reply to this message Reply
Hi!
Can anyone tell me how to create a function which returns an initial string in reverse. I think you have to use another string where the characters of the initial string are appended backwards.

E.g Initial string = "Hello"
Returned string = "olleH"

Thanks
NM

Ramu

Posts: 29
Nickname: sripoorna
Registered: Oct, 2002

Re: how..? Posted: Oct 25, 2002 7:02 PM
Reply to this message Reply
hi,
Create a StringBuffer object from your string then call the reverse() method on it. This simply reverses the contents of it.

Simple when you know how.

regards
ramu

Nimesh

Posts: 7
Nickname: nm
Registered: Oct, 2002

Re: how..? Posted: Oct 27, 2002 7:28 AM
Reply to this message Reply
OK thanx.
I got it working...but how do I get it into a function so that it returns the reversed string. I've only been doing Java for 3 days so any examples of code would be great.

Thanx. NM

Flat View: This topic has 4 replies on 1 page
Topic: Microsoft java VM Previous Topic   Next Topic Topic: Static Variables Storage

Sponsored Links



Google
  Web Artima.com   

Copyright © 1996-2019 Artima, Inc. All Rights Reserved. - Privacy Policy - Terms of Use