OK so this java application is not so serious, but it does include a class with a main(), an int and a String variable, a while loop, and an if test. A little more polish and I’ll be building that brewery back end in no time.
And the output when the class/app is run:
5 bottles of beer. You take one down. You pass it around. 4 bottles of beer on the wall. 4 bottles of beer on the wall. 4 bottles of beer. You take one down. You pass it around. 3 bottles of beer on the wall. 3 bottles of beer on the wall. 3 bottles of beer. You take one down. You pass it around. 2 bottles of beer on the wall. 2 bottles of beer on the wall. 2 bottles of beer. You take one down. You pass it around. 1 bottle of beer on the wall. 1 bottle of beer on the wall. 1 bottle of beer. You take one down. You pass it around. No more bottles of beer on the wall.
I recommend the book Head First Java if you want to learn to write Java applications.