Counter program for java

Counter program for java

The problem is to count from 000 to 444 with recursion. The maximum digit is 4 so that the program will count from 000,001,002,003,004,010, 011 and so on. How can I solve this?

View Answers

May 8, 2012 at 5:15 PM

The given code create a recursive function to count numbers from 000 to 444 as string. The maximum digit is 4.

import java.util.*;
class PrintNumbers 
{
    static public void findNumbers(String[] array, List<String> list, String st, int depth) {
        if (st.length() >= depth)
           return;
        for (String s : array) {
            String str=st+s;
            list.add(str);
            findNumbers(array, list, str, depth);
        }
        for (int i=0; i<list.size(); i++){
        if(list.get(i).length()<3){
            list.remove(i);  
        }
      }
    }
    public static void main(String[] args) {
        String[] numbers = {"0", "1", "2", "3", "4"};
        ArrayList<String> list = new ArrayList<String>();
        findNumbers(numbers, list, "", 3);
        System.out.println(list);
    }
}

May 9, 2012 at 1:00 AM

Thanks a lot.... Really appreciate...









Related Tutorials/Questions & Answers:
Counter program for java
Counter program for java  The problem is to count from 000 to 444 with recursion. The maximum digit is 4 so that the program will count from 000,001,002,003,004,010, 011 and so on. How can I solve
character counter - Java Beginners
of the entered(by user) name?  hy katy, import java.io.*; class counter { public counter() { System.out.print("Enter ur name:"); try... void main(String args[]) { new counter(); } } this code
Advertisements
Hit Counter Schema using java script - WebSevices
Hit Counter Schema using java script   Dear Sir, I am sending you none project i need you help please tell me how to do it? first I have... counter of 0-9 and then switch to an alphabet for 10 and above. After going over
java main program
java main program  how to write a main program for the following code...++) { //Look backward int counter = 0; while(counter <= mRange && i >= 0 && counter <= i
Create a counter in mySQL 5 database through Java - SQL
Create a counter in mySQL 5 database through Java  Dear Editor, Thanks for your valuable Java code example for JFileChooser. I had another question regarding Java & mySQL 5 database
ModuleNotFoundError: No module named 'Counter'
ModuleNotFoundError: No module named 'Counter'  Hi, My Python program is throwing following error: ModuleNotFoundError: No module named 'Counter' How to remove the ModuleNotFoundError: No module named 'Counter
ModuleNotFoundError: No module named 'Counter'
ModuleNotFoundError: No module named 'Counter'  Hi, My Python program is throwing following error: ModuleNotFoundError: No module named 'Counter' How to remove the ModuleNotFoundError: No module named 'Counter
ModuleNotFoundError: No module named 'Counter'
ModuleNotFoundError: No module named 'Counter'  Hi, My Python program is throwing following error: ModuleNotFoundError: No module named 'Counter' How to remove the ModuleNotFoundError: No module named 'Counter
Servlet Counter
{ int counter = 0; public void doGet(HttpServletRequest request...(); counter++; pw.println("At present the value of the counter is " + counter); } } In the above example, which keeps track how many times the servlet
Java Program - Java Beginners
Java Program  Write a program that demonstrates the use... threads should represent the counters as follows : 1) One counter starts from 5 and increments with the step of 5. 2) Second counter starts from 10
Java Program - Java Beginners
Java Program  Write a program that demonstrates the use... threads should represent the counters as follows : 1) One counter starts from 5 and increments with the step of 5. 2) Second counter starts from 10
Simple Counter In Servlet
a program on counter which will keep track how many times the servlet has been accessed.  To make this program firstly we have to make one class... Simple Counter in Servlet     
Counter
ModuleNotFoundError: No module named 'error-counter'
ModuleNotFoundError: No module named 'error-counter'  Hi, My Python program is throwing following error: ModuleNotFoundError: No module named 'error-counter' How to remove the ModuleNotFoundError: No module named
ModuleNotFoundError: No module named 'moca-counter'
ModuleNotFoundError: No module named 'moca-counter'  Hi, My Python program is throwing following error: ModuleNotFoundError: No module named 'moca-counter' How to remove the ModuleNotFoundError: No module named '
ModuleNotFoundError: No module named 'moca-counter'
ModuleNotFoundError: No module named 'moca-counter'  Hi, My Python program is throwing following error: ModuleNotFoundError: No module named 'moca-counter' How to remove the ModuleNotFoundError: No module named '
ModuleNotFoundError: No module named 'page-counter'
ModuleNotFoundError: No module named 'page-counter'  Hi, My Python program is throwing following error: ModuleNotFoundError: No module named 'page-counter' How to remove the ModuleNotFoundError: No module named '
ModuleNotFoundError: No module named 'pdf-counter'
ModuleNotFoundError: No module named 'pdf-counter'  Hi, My Python program is throwing following error: ModuleNotFoundError: No module named 'pdf-counter' How to remove the ModuleNotFoundError: No module named '
ModuleNotFoundError: No module named 'rip-counter'
ModuleNotFoundError: No module named 'rip-counter'  Hi, My Python program is throwing following error: ModuleNotFoundError: No module named 'rip-counter' How to remove the ModuleNotFoundError: No module named '
ModuleNotFoundError: No module named 'tag_counter'
ModuleNotFoundError: No module named 'tag_counter'  Hi, My Python program is throwing following error: ModuleNotFoundError: No module named 'tag_counter' How to remove the ModuleNotFoundError: No module named '
ModuleNotFoundError: No module named 'verb_counter'
ModuleNotFoundError: No module named 'verb_counter'  Hi, My Python program is throwing following error: ModuleNotFoundError: No module named 'verb_counter' How to remove the ModuleNotFoundError: No module named '
ModuleNotFoundError: No module named 'words_counter'
ModuleNotFoundError: No module named 'words_counter'  Hi, My Python program is throwing following error: ModuleNotFoundError: No module named 'words_counter' How to remove the ModuleNotFoundError: No module named
ModuleNotFoundError: No module named 'words_counter'
ModuleNotFoundError: No module named 'words_counter'  Hi, My Python program is throwing following error: ModuleNotFoundError: No module named 'words_counter' How to remove the ModuleNotFoundError: No module named
ModuleNotFoundError: No module named 'calorie-counter'
ModuleNotFoundError: No module named 'calorie-counter'  Hi, My Python program is throwing following error: ModuleNotFoundError: No module named 'calorie-counter' How to remove the ModuleNotFoundError: No module named
ModuleNotFoundError: No module named 'counter-caller'
ModuleNotFoundError: No module named 'counter-caller'  Hi, My Python program is throwing following error: ModuleNotFoundError: No module named 'counter-caller' How to remove the ModuleNotFoundError: No module named
ModuleNotFoundError: No module named 'counter-robots'
ModuleNotFoundError: No module named 'counter-robots'  Hi, My Python program is throwing following error: ModuleNotFoundError: No module named 'counter-robots' How to remove the ModuleNotFoundError: No module named
ModuleNotFoundError: No module named 'django-counter'
ModuleNotFoundError: No module named 'django-counter'  Hi, My Python program is throwing following error: ModuleNotFoundError: No module named 'django-counter' How to remove the ModuleNotFoundError: No module named
ModuleNotFoundError: No module named 'error-counter'
ModuleNotFoundError: No module named 'error-counter'  Hi, My Python program is throwing following error: ModuleNotFoundError: No module named 'error-counter' How to remove the ModuleNotFoundError: No module named
ModuleNotFoundError: No module named 'incremental-counter'
ModuleNotFoundError: No module named 'incremental-counter'  Hi, My Python program is throwing following error: ModuleNotFoundError: No module named 'incremental-counter' How to remove the ModuleNotFoundError
ModuleNotFoundError: No module named 'counter-caller'
ModuleNotFoundError: No module named 'counter-caller'  Hi, My Python program is throwing following error: ModuleNotFoundError: No module named 'counter-caller' How to remove the ModuleNotFoundError: No module named
ModuleNotFoundError: No module named 'counter-robots'
ModuleNotFoundError: No module named 'counter-robots'  Hi, My Python program is throwing following error: ModuleNotFoundError: No module named 'counter-robots' How to remove the ModuleNotFoundError: No module named
ModuleNotFoundError: No module named 'incremental-counter'
ModuleNotFoundError: No module named 'incremental-counter'  Hi, My Python program is throwing following error: ModuleNotFoundError: No module named 'incremental-counter' How to remove the ModuleNotFoundError
ModuleNotFoundError: No module named 'line-counter'
ModuleNotFoundError: No module named 'line-counter'  Hi, My Python program is throwing following error: ModuleNotFoundError: No module named 'line-counter' How to remove the ModuleNotFoundError: No module named '
ModuleNotFoundError: No module named 'moca-counter'
ModuleNotFoundError: No module named 'moca-counter'  Hi, My Python program is throwing following error: ModuleNotFoundError: No module named 'moca-counter' How to remove the ModuleNotFoundError: No module named '
ModuleNotFoundError: No module named 'morris-counter'
ModuleNotFoundError: No module named 'morris-counter'  Hi, My Python program is throwing following error: ModuleNotFoundError: No module named 'morris-counter' How to remove the ModuleNotFoundError: No module named
ModuleNotFoundError: No module named 'pdf-counter'
ModuleNotFoundError: No module named 'pdf-counter'  Hi, My Python program is throwing following error: ModuleNotFoundError: No module named 'pdf-counter' How to remove the ModuleNotFoundError: No module named '
ModuleNotFoundError: No module named 'reference_counter'
ModuleNotFoundError: No module named 'reference_counter'  Hi, My Python program is throwing following error: ModuleNotFoundError: No module named 'reference_counter' How to remove the ModuleNotFoundError: No module
ModuleNotFoundError: No module named 'tipfy.ext.sharded_counter'
ModuleNotFoundError: No module named 'tipfy.ext.sharded_counter'  Hi, My Python program is throwing following error: ModuleNotFoundError: No module named 'tipfy.ext.sharded_counter' How to remove
ModuleNotFoundError: No module named 'word-counter'
ModuleNotFoundError: No module named 'word-counter'  Hi, My Python program is throwing following error: ModuleNotFoundError: No module named 'word-counter' How to remove the ModuleNotFoundError: No module named '
ModuleNotFoundError: No module named 'words_counter'
ModuleNotFoundError: No module named 'words_counter'  Hi, My Python program is throwing following error: ModuleNotFoundError: No module named 'words_counter' How to remove the ModuleNotFoundError: No module named
ModuleNotFoundError: No module named 'words_counter'
ModuleNotFoundError: No module named 'words_counter'  Hi, My Python program is throwing following error: ModuleNotFoundError: No module named 'words_counter' How to remove the ModuleNotFoundError: No module named
ModuleNotFoundError: No module named 'words_counter'
ModuleNotFoundError: No module named 'words_counter'  Hi, My Python program is throwing following error: ModuleNotFoundError: No module named 'words_counter' How to remove the ModuleNotFoundError: No module named
ModuleNotFoundError: No module named 'distributed-counter'
ModuleNotFoundError: No module named 'distributed-counter'  Hi, My Python program is throwing following error: ModuleNotFoundError: No module named 'distributed-counter' How to remove the ModuleNotFoundError
java program - Java Beginners
it will b cleared.the program should b done onlu using java applet but not with swing...java program  there are two buttons-one for "show" and the other...(); int f1, f2 = 0, f3 = 1; int counter=0; int num=10; String n
Java Program - Java Beginners
Java Program  The numbers in the following sequence are called... a program using doâ?¦..while loop to calculate and print the first m Fibonacci numbers...: public class FibonacciSeries { int counter=0; public void generateSeries(int num
java program for
java program for   java program for printing documents,images and cards
SHOPPING COUNTER
with swtich case from the java. thanks for helps.   Hi Friend,ADS
a Java program
a Java program    Write a Java program to print even numbers from 2 to 1024? Write a Java program to print ? My Name is Mirza? 100 times? Write a Java program to print Fibonacci Series? Write a Java program to reverse a number
Java Program
Java Program  A Java Program that print the data on the printer but buttons not to be printed
java program
java program  write a program to print 1234 567 89 10

Ads