Maintainable and Adaptable FizzBuzz implementation Something I haven't often seen in FizzBuzz implementation is a focus on making it flexible and maintainable. I have attempted to create a version that prioritizes these, such as by making it easier to change the conditions and add more conditions. What else could I do to work towards these criteria?

public class V3_ifFunc
{
   public static void main(String[] args)
   {
       String out;
       int i;
       for(i=0; i&lt;=100; i++)
       {
           out = "";
           if(divisible(i, 3)){
               out += "Fizz";
           }
           if(divisible(i, 5)){
               out += "Buzz";
           }
           if(out.equals("")){
               out += Integer.toString(i);
           }
           System.out.println(out);
       }
   }
   public static boolean divisible(int i, int by)
   {
       if(i%by==0){
           return true;
       }else{
           return false;
       }
   }
}
You could make some sort of struct or class that stores the text printout and the number i should be divisible by. Then you just need to create as many instances of the class as you need and loop through them. 

One other approach is to have a hashtable and store the keys in an array that you loop through. You can use whichever one you feel makes the most sense but the first method should technically use up less memory because you only store the text once for each condition. I might be wrong though, I don't really use Java.

Example (Not tested and not written by a Java developer):

class Condition {
    String printout;
    int div;
}

Condition[] conditions = { {"Fizz", 3}, {"Buzz", 5} };
int loops = 100;

public static void main() {
   for(int i = 0; i &lt; loops; i++) {
       String printOut = "";
       for(int j = 0; j &lt; conditions.length; i++) {
           if(i % conditions[j] == 0) {
              printOut += conditions[j].printout;
           }
       }
       if(printOut == "") {
          System.out.println(Integer.toString(i));
       } else {
          System.out.println(printOut);
       }
   }
}


Then if you want to you could wrap it in a function and call it with the conditions array and number of loops as parameters.

You can also shorten your divisible to:

public static boolean divisible(int a, int b) {
   return ((a % b) == 0);
}


But I think that you don't really need that function because you can just use the % operator and your code would be cleaner and quicker to understand. Just for future consideration.

Hope this answers your question.