Results 1 to 2 of 2
Thread: Writing a recursive method :S
- 12-06-2009, 02:56 PM #1
Member
- Join Date
- Dec 2009
- Posts
- 5
- Rep Power
- 0
Writing a recursive method :S
So I wanted to write a program which, with a recursive method tell me how many numbers there are in a given number. But it doesn't work, can anyone please help me with it?
import java.util.*;
public class Test27{
public static void main(String[] args){
nbrOfDig(1337);
c = 0;
static void nbrOfDig(int n){ \\ illegal start of expression ??
c++;
if(n > 10){
nbrOfDig(n%10);
}
else{
System.out.println(c);
}
}
} \\ expected ; ??
}
- 12-06-2009, 03:13 PM #2
- Join Date
- Sep 2008
- Location
- Voorschoten, the Netherlands
- Posts
- 11,604
- Blog Entries
- 7
- Rep Power
- 17
Similar Threads
-
recursive method problem
By melody in forum New To JavaReplies: 1Last Post: 10-29-2009, 07:15 AM -
Recursive method using int array, help needed
By chupalo17 in forum New To JavaReplies: 4Last Post: 09-07-2009, 11:15 PM -
Java Recursive method problem
By kj2009 in forum Advanced JavaReplies: 2Last Post: 02-25-2009, 03:19 PM -
exercise of recursive method
By amexudo in forum New To JavaReplies: 2Last Post: 03-09-2008, 05:55 PM -
Recursive Method
By bluegreen7hi in forum New To JavaReplies: 5Last Post: 11-29-2007, 04:45 AM


LinkBack URL
About LinkBacks
Reply With Quote
Bookmarks