# FizzBuzz program in java In this post, we will see how to program FizzBuzz in java.

`Fizzbuzz` is a fun game played generally by school children. It is simple game in which when your turn comes, you need to say the next number. So here are rules of the game:

• If number is divisible by `3`, then you need to say `Fizz`
• If number is divisible by `5`, then you need to say `Buzz`
• If number is divisible by `3` and `5` both, then you need to say `FizzBuzz`
• Else you just need to say `next number`

For example:

If there are 20 children then number will be printed as below:

1 2 Fizz 4 Buzz Fizz 7 8 Fizz Buzz 11 Fizz 13 14 FizzBuzz 16 17 Fizz 19 Buzz

## Simple FizzBuzz Java solution

Here is simple FizzBuzz java solution

Output of above program will be:

Enter number:
20
The FizzBuzz numbers will be:
1 2 Fizz 4 Buzz Fizz 7 8 Fizz Buzz 11 Fizz 13 14 FizzBuzz 16 17 Fizz 19 Buzz

## Java FizzBuzz program using Java 8

Here is the one line solution for Java 8 using Java 8 Stream

Complete java FizzBuzz program

When you run above program, you will get below output:

Enter number:
15
1 2 Fizz 4 Buzz Fizz 7 8 Fizz Buzz 11 Fizz 13 14 FizzBuzz

That’s all about FizzBuzz program in java.

import_contacts

### You may also like: ## Related Posts

• 08 May

### Star Pattern programs in Java

Learn about how to print different star pattern in java.

• 17 April

### Convert Roman Number to Integer in Java

Learn about how to convert Roman number to Integer in java.

• 30 December

### Rock Paper Scissors Game in Java

Learn about how to implement Rock Paper Scissors game in java.

• 25 December

### Find automorphic number in java

Learn about how to find automorphic number in java using different methods

• 25 December

### Find nth prime number in java

Learn about how to find nth prime number in java.

• 06 October

### Implement distance formula in java

In this post, we will see how to implement distance formula between two points in java. Formula to find distance between two points ( x1, y1) and (x2 , y2) is d= sqrt( (x2-x1)^2+ (y2 – y1)^2) Here is simple program to calculate distance between two points in java. [crayon-6330172b25139689088043/] Here we have used math.sqrt […]

## Subscribe to our newletter

Get quality tutorials to your inbox. Subscribe now.