Latest Tutorials| Questions and Answers|Ask Questions?|Site Map



Home Answers Viewqa Java-Beginners Counter program for java

Have Programming Question? Ask it here!
 
 
 


aerodeus
Counter program for java
2 Answer(s)      a year and 11 months ago
Posted in : Java Beginners


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?


Advertisement
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
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
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
SHOPPING COUNTER
the java. thanks for helps.   Hi Friend, Try the following code
Simple Counter In Servlet
a program on counter which will keep track how many times the servlet has been...;counter);   } } The output of the program... Simple Counter in Servlet     
counter - JSP-Interview Questions
using java technology,i explained we can do that by using jsp and servlets...********///////// A page with a counter This page has been visited: times. This counter never increases its value
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
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
Threading in Java
, program counter and lifetime.   Life Cycle of A Thread... Threading in Java      ... is very important in Java Programing language. A thread is a sequential path
java program for
java program for   java program for printing documents,images and cards
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
Java Program  A Java Program that print the data on the printer but buttons not to be printed
Using Bean Counter in JSP
Using Bean Counter in JSP       In this section you will learn how the counter bean can be used in jsp. As you all know a counter increments the value by one. Here, we will use
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 Beginners
Java Program  Write a program that prints prime numbers between 1 to n. Number n should be acepted as command line input.  Hi Friend... = ""; int counter = 0; System.out.println("Prime Numbers between 1 to "+num
java program
java program  write a program to print 1234 567 89 10
java program
java program  how to write an addition program in java without using arithematic operator
java program
java program  write java program for constructor,overriding,overriding,exception handling
java program
java program  write a java program to display array list and calculate the average of given array
java program
java program  write a java program to display array list and calculate the average of given array
Java Program
Java Program  java program to insert row in excel sheet after identifying an object
java program
java program  java program to implement the reflection of a particular class details like constructor,methods and fields with its modifiers
java program
java program  Write a java program to do matrix addition operation On two given matrices
java program
java program  Write a java program to find the number of Positive numbers in m* n matrix
java program
java program  Write a program to create an applet and display The message "welcome to java
Java Program - Java Beginners
Java Program  Write a program that detects successive repeated occurrence of a letter in a word. For example, in the word ‚??explanation‚?? letter ‚...(" ", ""); char[]third =st.toCharArray(); for(int counter =0;counter=0
java program
java program  Write a program to demonstrate the concept of various possible exceptions arising in a Java Program and the ways to handle them.  ... in Java
java program
java program  write a java program to compute area of a circle.square,rectangle.triangle,volume of a sphere ,cylinder and perimeter of cube using method over riding
java program
java program  write a java program to compute area of a circle.square,rectangle.triangle,volume of a sphere ,cylinder and perimeter of cube using method over riding
java program
java program   Write a program to find the difference between sum of the squares and the square of the sums of n numbers
java program
java program  write a program to create text area and display the various mouse handling events
java program
java program  Develop the program calculatePipeArea. It computes the surface area of a pipe, which is an open cylinder. The program accpets three values: the pipes inner radius, its length, and the thickness of its wall
java program
java program  . Develop the program calculatePipeArea. It computes the surface area of a pipe, which is an open cylinder. The program accpets three values: the pipes inner radius, its length, and the thickness of its wall
java program
java program  . Write a program which performs to raise a number to a power and returns the value. Provide a behavior to the program so as to accept any type of numeric values and returns the results
Java program
Java program  Write a program which performs to raise a number to a power and returns the value. Provide a behavior to the program so as to accept any type of numeric values and returns the results
program in java
program in java  write a reverse program in java using string buffer.the input and out put as follows. input- hi good mornig out put-ih doog ginrom
java program
java program   A B C D E F F E D C B A A B C D E E D C B A A B C D D C B A A B C C B A A B B A A A java program to display above triangle
java program
java program  write a program to create server and client such that server receives data from client using BuuferedReader and sends reply to client using PrintStream
java program
java program  write a program to read 10 numbers from user and store it in a array. display the maximum n minimum number in the array
java program
java program  write a java program to read a file which hold email address validate email address tohave formate @.* and replace all .com email address
java program
java program  write a java program to create an array of size 10 by taking input from bufferreader and find out the average of array elements from that array
java program
java program  write a java program to create an array of size 10 by taking input from bufferreader and find out the average of array elements from that array
java program
java program  write a java program to create an array of size 10 by taking input from bufferreader and find out the average of array elements from that array
Java Program
Java Program  I want to Write a program in JAVA to display to create a class called MATRIX using a two-dimensional array of integers. Perform the addition and subtraction of two matrices. Help me
java program
java program  i want a applet program that accepts two input strings using tag and concatenate the strings and display it in status window. please give mi he code for this in core java
 

 

 

DMCA.com