Look at this funny Java code:
Main.java
Code:
/*
* Main.java
* Bomb - this is just a working joke code.
*/
package bomb;
/**
* @author jirachifan
*/
public class Main {
/**
* @param args the command line arguments
*/
public static void main(String[] args) throws Bomb
{
try
{
throw new Bomb("you");
}
catch(Bomb the_Bomb)
{
the_Bomb.Explode();
}
}
}
Bomb.java
Code:
/*
* Bomb.java
*/
package bomb;
/**
*
* @author jirachifan
*/
public class Bomb extends Exception
{
private String Target;
public Bomb(String theTarget)
{
System.out.println("The bomb was thrown to " + theTarget + ".\n");
Target = theTarget;
}
public void Explode()
{
System.out.println("BOOM!!\n");
if (Target.toString() == "you")
{
System.out.printf("%s are dead now.\n", Target);
}
else
{
System.out.printf("%s is dead now.\n", Target);
}
}
}
It outputs:
Code:
The bomb was thrown to you.
BOOM!!
you are dead now.