Reply
 
LinkBack Thread Tools Display Modes
  #1 (permalink)  
Old 10-24-2008, 12:01 PM
Member
 
Join Date: Oct 2008
Posts: 6
Rep Power: 0
Java01 is on a distinguished road
Default Recursion in Java ..
need help on recursion, i don't know how to add a character into a string. for example:

adding 'a' into position 5 for example.. into the string "bcdefg" so it would go after f.. I know you can use CharAt but all i need is a start, im having trouble starting the code

any help?
Bookmark Post in Technorati
Reply With Quote
  #2 (permalink)  
Old 10-24-2008, 12:22 PM
Member
 
Join Date: Oct 2008
Posts: 6
Rep Power: 0
Java01 is on a distinguished road
Default
any help? i got to have it working within 20 mins!
Bookmark Post in Technorati
Reply With Quote
  #3 (permalink)  
Old 10-24-2008, 12:28 PM
Eranga's Avatar
Moderator
 
Join Date: Jul 2007
Location: Colombo, Sri Lanka
Posts: 7,502
Rep Power: 11
Eranga has a spectacular aura aboutEranga has a spectacular aura about
Send a message via Yahoo to Eranga
Default
What you have done so far, can you show your code here.
__________________
Use an appropriate Subject. "Help, urgent!" isn't one.
Someone helped you? their helpful post.
Help:Forums FAQ|How To Ask Questions The Smart WayResources:The Java Tutorials|Glossary for Java|NetBeans IDE|Sun DownloadsWeb:WritOnceTips:Is your IDE the best?|Which Application Server?
Bookmark Post in Technorati
Reply With Quote
  #4 (permalink)  
Old 10-24-2008, 12:33 PM
Member
 
Join Date: Oct 2008
Posts: 6
Rep Power: 0
Java01 is on a distinguished road
Default
i havn't done much, i need help starting it off, i have a few notes here and there.. like :

public String rev3 (String str1, String str2, int num) {
if ((str1.length()) == 0) return str2;

im just really stuck lol, if you can help start me off i can get it hopefully!
Bookmark Post in Technorati
Reply With Quote
  #5 (permalink)  
Old 10-24-2008, 12:35 PM
Eranga's Avatar
Moderator
 
Join Date: Jul 2007
Location: Colombo, Sri Lanka
Posts: 7,502
Rep Power: 11
Eranga has a spectacular aura aboutEranga has a spectacular aura about
Send a message via Yahoo to Eranga
Default
This is not related with recursion. I don't know from where you came with that word.

Here is a simple way to do it.

Code:
        String str = "bcdefg";
        str = str.substring(0, 4) + "a" + str.substring(4);
        System.out.println(str);
__________________
Use an appropriate Subject. "Help, urgent!" isn't one.
Someone helped you? their helpful post.
Help:Forums FAQ|How To Ask Questions The Smart WayResources:The Java Tutorials|Glossary for Java|NetBeans IDE|Sun DownloadsWeb:WritOnceTips:Is your IDE the best?|Which Application Server?
Bookmark Post in Technorati
Reply With Quote
  #6 (permalink)  
Old 10-24-2008, 12:40 PM
Member
 
Join Date: Oct 2008
Posts: 6
Rep Power: 0
Java01 is on a distinguished road
Default
oh ok, we got taught that way in lectures, we used a method called rev3, recursion but thanks!
Bookmark Post in Technorati
Reply With Quote
  #7 (permalink)  
Old 10-24-2008, 12:42 PM
Eranga's Avatar
Moderator
 
Join Date: Jul 2007
Location: Colombo, Sri Lanka
Posts: 7,502
Rep Power: 11
Eranga has a spectacular aura aboutEranga has a spectacular aura about
Send a message via Yahoo to Eranga
Default
That's why best to use a descriptive name for method defining.
__________________
Use an appropriate Subject. "Help, urgent!" isn't one.
Someone helped you? their helpful post.
Help:Forums FAQ|How To Ask Questions The Smart WayResources:The Java Tutorials|Glossary for Java|NetBeans IDE|Sun DownloadsWeb:WritOnceTips:Is your IDE the best?|Which Application Server?
Bookmark Post in Technorati
Reply With Quote
Reply

Bookmarks

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

BB 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
java recursion infinite loop tony404 Advanced Java 9 10-03-2008 02:16 PM
help with recursion Nari New To Java 15 04-24-2008 10:13 AM
i could not get the recursion in java sivasayanth New To Java 3 04-23-2008 09:08 AM
Help With Recursion andrew777 New To Java 1 03-29-2008 01:51 PM
Recursion in java lenny Advanced Java 1 08-07-2007 07:23 AM


All times are GMT +2. The time now is 06:02 AM.



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