User Name Password Register
DaniWeb IT Discussion Community
All
What is DaniWeb IT Discussion Community?
You're currently browsing the Java section within the Software Development category of DaniWeb, a massive community of 427,935 software developers, web developers, Internet marketers, and tech gurus who are all enthusiastic about making contacts, networking, and learning from each other. In fact, there are 2,960 IT professionals currently interacting right now! Registration is free, only takes a minute and lets you enjoy all of the interactive features of the site.
Please support our Java advertiser: Lunarpages Java Web Hosting
Views: 319 | Replies: 7
Reply
Join Date: Jul 2008
Posts: 8
Reputation: d4n0wnz is an unknown quantity at this point 
Rep Power: 0
Solved Threads: 0
d4n0wnz d4n0wnz is offline Offline
Newbie Poster

quick java question(chars)

  #1  
Jul 16th, 2008
I'm trying to write a recursive method that will print a char c, x amount of times on the same line. I was thinking that I could return the recursive function call and concatenate the char c but I don't think my compiler agrees. What exactly are the properties of chars and how can I go about doing this?
AddThis Social Bookmark Button
Reply With Quote  
Join Date: Dec 2007
Location: Greece
Posts: 560
Reputation: javaAddict will become famous soon enough javaAddict will become famous soon enough 
Rep Power: 3
Solved Threads: 63
javaAddict's Avatar
javaAddict javaAddict is offline Offline
Posting Pro

Re: quick java question(chars)

  #2  
Jul 16th, 2008
What is your code
I AM the 12th CYLON
Reply With Quote  
Join Date: Jul 2008
Posts: 51
Reputation: Vilice is an unknown quantity at this point 
Rep Power: 0
Solved Threads: 0
Vilice Vilice is offline Offline
Junior Poster in Training

Re: quick java question(chars)

  #3  
Jul 17th, 2008
extend the char ,make it a object
Reply With Quote  
Join Date: Dec 2007
Location: Greece
Posts: 560
Reputation: javaAddict will become famous soon enough javaAddict will become famous soon enough 
Rep Power: 3
Solved Threads: 63
javaAddict's Avatar
javaAddict javaAddict is offline Offline
Posting Pro

Re: quick java question(chars)

  #4  
Jul 17th, 2008
Originally Posted by Vilice View Post
extend the char ,make it a object


Cannot extend char (Character class). It is final.
I AM the 12th CYLON
Reply With Quote  
Join Date: Aug 2007
Location: Bangalore, India
Posts: 101
Reputation: ChaseVoid is an unknown quantity at this point 
Rep Power: 0
Solved Threads: 10
ChaseVoid's Avatar
ChaseVoid ChaseVoid is offline Offline
Junior Poster

Re: quick java question(chars)

  #5  
Jul 17th, 2008
Can't you just store the values on a String and then accept a value for the count of recursion. Call the method passing the String and Integer.

If you must use a char data type, then is a simple typecasting.
Reply With Quote  
Join Date: Jul 2008
Posts: 51
Reputation: Vilice is an unknown quantity at this point 
Rep Power: 0
Solved Threads: 0
Vilice Vilice is offline Offline
Junior Poster in Training

Re: quick java question(chars)

  #6  
Jul 18th, 2008
I mean the superclass of the char .Or can extend other original data type , give it more function
Reply With Quote  
Join Date: Aug 2007
Location: Bangalore, India
Posts: 101
Reputation: ChaseVoid is an unknown quantity at this point 
Rep Power: 0
Solved Threads: 10
ChaseVoid's Avatar
ChaseVoid ChaseVoid is offline Offline
Junior Poster

Re: quick java question(chars)

  #7  
Jul 18th, 2008
>I mean the superclass of the char .Or can extend other original data type ,
>give it more function
Why do you want to bother doing all that stuff? When a simple typecasting is enough.
Reply With Quote  
Join Date: Jul 2008
Posts: 51
Reputation: Vilice is an unknown quantity at this point 
Rep Power: 0
Solved Threads: 0
Vilice Vilice is offline Offline
Junior Poster in Training

Re: quick java question(chars)

  #8  
Jul 21st, 2008
Yeah ,I feel like I always want to exten sth ,Isn't stupid ?
Reply With Quote  
Reply

Only community members can participate in forum threads. You must register or log in to contribute.

DaniWeb Java Marketplace
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)

 

Thread Tools Display Modes

Other Threads in the Java Forum

All times are GMT -4. The time now is 6:27 pm.
Forum system based on vBulletin Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
©2003 - 2008 DaniWeb® LLC