Java Forums

Main Menu
Home
Today's Posts
FAQ
Search
Contact Us

Java Network
Linux Archive
Java Tips
Java Tips Blog

Sponsored Links





Welcome to the Java Forums.

You are currently viewing our boards as a guest which gives you limited access to view most discussions and access our other features. By joining our free community, you will:

  • have access to post topics
  • communicate privately with other members (PM)
  • not see advertisements between posts
  • have the possibility to earn one of our surprises if you are an active member
  • access many other special features that will be introduced later.

Registration is fast, simple and absolutely free so please, join our community today!

If you have any problems with the registration process or your account login, please contact us.

Reply
 
LinkBack Thread Tools Display Modes
  #1 (permalink)  
Old 09-15-2008, 02:50 AM
Member
 
Join Date: Sep 2008
Posts: 15
pjr5043 is on a distinguished road
how do i make a string return a number?
for example .. how can i edit this code to return a number?
Code:
String whatIsUp() { double r = 0; int n=0; String b = "......"; r = (Math.random()*10); n = (int)r; System.out.println("just for you to have an idea of the value of r and n =>>"+ " r="+r+",n="+n); if (n == 0) b = "reading"; if (n == 1) b = "talking"; if (n == 2) b = "interacting"; if (n == 3) b = "wildly coding in Java"; if (n == 4) b = "sound asleep while instructor is talking some Java stuff"; return b; }
Bookmark Post in Technorati
Reply With Quote
Sponsored Links
  #2 (permalink)  
Old 09-15-2008, 04:42 AM
Fubarable's Avatar
Senior Member
 
Join Date: Jun 2008
Posts: 883
Fubarable is on a distinguished road
Code:
int whatIsUp() { int n = 0; //... lot of stuff return n }
Bookmark Post in Technorati
Reply With Quote
  #3 (permalink)  
Old 09-15-2008, 04:51 AM
Member
 
Join Date: Sep 2008
Posts: 15
pjr5043 is on a distinguished road
ok thanks .. i'm trying to call on it in an app but its not working .. when it was a string i would call on it like gr1.participate1() and that would do it, but now since its an int do i need to do something different?
Bookmark Post in Technorati
Reply With Quote
  #4 (permalink)  
Old 09-15-2008, 05:04 AM
Member
 
Join Date: Sep 2008
Posts: 15
pjr5043 is on a distinguished road
nvmd got it .. thank you very much
Bookmark Post in Technorati
Reply With Quote
  #5 (permalink)  
Old 09-15-2008, 06:18 AM
Eranga's Avatar
Moderator
 
Join Date: Jul 2007
Location: Colombo, Sri Lanka
Posts: 4,564
Eranga has a spectacular aura aboutEranga has a spectacular aura about
Send a message via Yahoo to Eranga
Are you trying to return an int value or a string converted into int value number?

If you have solve the problem please mark it as solved.
__________________
Use an appropriate Subject. "Help, urgent!" isn't one.
To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.

Has someone helped you? Then you can
To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
their helpful post.

Want to make your IDE the best?
To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.

To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.

To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
Bookmark Post in Technorati
Reply With Quote
  #6 (permalink)  
Old 09-15-2008, 06:43 AM
Member
 
Join Date: Sep 2008
Posts: 15
pjr5043 is on a distinguished road
i solved it .. thank you
Bookmark Post in Technorati
Reply With Quote
  #7 (permalink)  
Old 09-15-2008, 06:56 AM
Eranga's Avatar
Moderator
 
Join Date: Jul 2007
Location: Colombo, Sri Lanka
Posts: 4,564
Eranga has a spectacular aura aboutEranga has a spectacular aura about
Send a message via Yahoo to Eranga
Ok, mark it as solved.
__________________
Use an appropriate Subject. "Help, urgent!" isn't one.
To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.

Has someone helped you? Then you can
To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
their helpful post.

Want to make your IDE the best?
To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.

To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.

To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
Bookmark Post in Technorati
Reply With Quote
Sponsored Links
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
the number of occurrences of each alphabetical letter in the string. masaka New To Java 20 05-14-2008 11:42 AM
HashMap String Return kizilbas1 New To Java 1 03-10-2008 05:34 AM
make a variable name from a string? Kinnikinnick New To Java 3 11-13-2007 05:54 PM
Will make a pyramid of some kind out of a number romina New To Java 1 08-07-2007 07:20 AM
how to convert String number to int gabriel New To Java 3 08-02-2007 06:46 AM


All times are GMT +3. The time now is 10:18 AM.


VBulletin, Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO ©2007, Crawlability, Inc.
Copyright ©2006 - 2007, www.java-forums.org