Voting

Category

real language

Bookmarking

Del.icio.us Digg Diigo DZone Earthlink Google Kick.ie
Windows Live LookLater Ma.gnolia Reddit Rojo StumbleUpon Technorati

Language Visual J++

(Microsoft's failed java before C#)

Date:02/25/08
Author:Reuben Saunders
URL:n/a
Comments:1
Info:http://en.wikipedia.org/wiki/J%2B%2B
Score: (2.78 in 9 votes)
public class EOP99Bottles
{
    public static void main(String[] args)
    {
	try
	{
	    throw new BottleException(1, null);
	}
	catch (Exception e)
	{
	    e.printStackTrace();
	}
    }
    private static class BottleException extends Exception
    {
	private final int cnt;
	public BottleException(int i, BottleException c)
	throws BottleException
	{
	    super(c);
	    this.cnt = i;
	    try
	    {
		int a  = 03 / (99-i);
		throw new BottleException(i+1, this);
	    }
	    catch (ArithmeticException e)
	    {
		//deliberately
	    }
	}
	public  void printStackTrace()
	{
	    System.out.println(cnt+" Bottle(s) of beer on the wall,"+cnt+"bottle(s) of beer");
	    System.out.println("Take one down and pass it around,");
	    System.out.println((cnt-1)+" bottle(s) of beer on the wall");
	    try
	    {
		getCause().printStackTrace();
	    }
	    catch (NullPointerException npe)
	    {
	    }
	    
	}
    }
    
}

Download Source | Write Comment

Alternative Versions

Comments

>>  Souvey said on 03/03/08 20:09:13

Souvey Awesome.

Download Source | Write Comment

Add Comment

Please provide a value for the fields Name, Comment and Security Code.
This is a gravatar-friendly website.
E-mail addresses will never be shown.
Enter your e-mail address to use your gravatar.

Please don't post large portions of code here! Use the form to submit new examples or updates instead!

Name:

eMail:

URL:

Security Code:
  
Comment: