# What does this Java main() method represent?

The main() method in the following Java program is a text rebus. What does it represent?

import java.util.*;
import java.awt.geom.*;

public class WhatDoesMainRepresent {
private static HashSet<Obj> hashSet = new HashSet<Obj>();
private static AffineTransform e = new AffineTransform();

static {
hashSet.add(new Obj());
}

public static void main(String[] args) {
hashSet.add(new Obj());
e.rotate(Math.PI);
{}
}

private static class Obj {
public int hashCode() {
return 1;
}
}
}


Hints:

1. The AffineTransform object is named e for a reason.
2. The hashSet.add(new Obj()) line in the main() method represents a single word that is a verb. (So far that word has not been mentioned.)

• That hash method might have just made be cry... – Going hamateur Jul 27 '15 at 15:24
• I am now tempted to do a near identical puzzle where a string object "u" is placed with an object with a hashCode of 2. And getting rid of the affine transform. – Going hamateur Jul 27 '15 at 15:32
• @pacoverflow does it have something to do with Coffee and Pie? Like dipping Cracked Coffee Cake in Coffee at Starbucks? – kanchirk Jul 27 '15 at 18:36
• @kanchirk Nothing to do with coffee and pie. – pacoverflow Jul 27 '15 at 18:37
• Is that verb 'spin'? – CodeNewbie Jul 30 '15 at 5:35

## 5 Answers

It represents

Kaleidoscope

Reasoning:

The second add will have the object "collide" with the first on the hashset since they have the same hash code. e rotated 180 degees is "a". The empty curly braces are a new "scope". Collide+a+scope = kaleidoscope.

• I think you got it one note, the e rotated is definitely intended to be a schwa. But I like it. – Going hamateur Jul 30 '15 at 14:53
• Good job. I was definitely thinking of a schwa for the rotated e (it was another puzzle on this site). The a works almost as well, although it's dependent on the font. – pacoverflow Jul 30 '15 at 15:57

I shame myself with this guess if it turns out to be wrong, but I suspect the text is the idiom

The reasoning being:

Every key/value pair in a hash map is stored in a bin determined by its hash code. In this case the hashcode for all objects of the Obj class is identical, meaning such objects are stored in the same bin.

The e.rotate(Math.PI) statement performs a useless 180° inversion. The transform will therefore turn its operand around. The {} represents an empty block.

The static statement and initial statement in main adds an object to the same bin once and then twice.

Hence: bin around the block once or twice.

After typing this out, I realize how indescribably bad this pun is. I truly hope this isn't the correct answer. :P

• No need to worry, that's not the correct answer. :) +1 for a nice explanation though. – pacoverflow Jul 27 '15 at 19:16
• After reading that explanation, it's kinda hard to believe this isn't correct. +1 – Set Big O Jul 27 '15 at 19:38
• If the static statement isn't part of the answer, what is its purpose? The code will function the same without it. – Ian MacDonald Jul 27 '15 at 20:15
• @IanMacDonald As I understand it, the hashCode is used for performance, to find the item in the HashMap's internal buckets, not to identify an individual key within those buckets. As a quick test I just pasted the code to an editor, printed the size of the map and after the second put there are two items in it. – Kevin Rubin Jul 28 '15 at 18:04
• @pacoverflow: I overlooked the fact that you hadn't overridden equals. So possibly "two in a bucket", "twice in the bucket", "toss in the bucket", then possibly "turns over", "around", "dumps out", "overturns", then possibly "block", "empty", "nothing", "empty-handed". And because it's a rebus, "over", "under", "with", etc. can always play a part. A-aaaand... I've still got nothing. :P – COTO Jul 28 '15 at 20:18

I think the answer is:

Love story

Reasoning:

hashSet.add(new Obj());

Here an object is being stored in a hash set [STORE]

e.rotate(Math.PI);

Here the object e is having a 180 degree rotation applied [E ABOUT]

{}

This is an empty block, so this code does nothing, or love as nothing can be termed in tennis for example [LOVE]

So putting it together we have:

STORE E ABOUT LOVE i.e. STORY ABOUT LOVE or LOVE STORY

• +1 for a nice try, but if this is the correct answer, then the static initialization block is completely unnecessary. – pacoverflow Jul 30 '15 at 13:23
• @pacoverflow Hmm yes good point – Pete Jul 30 '15 at 13:51

Is it

Much Ado About Nothing

Building quite heavily COTO's answer:

There's much code before the main(), but then it adds (sounds vaguely like "Ado") one more element, a new Obj object, to the collection, so it doesn't have none or one, but rather, much content.

The e.rotate(Math.PI) being "about".

And the empty code block {} being "Nothing".

• Sorry that's not it. If I were going for "ado", I would have put in a do-while statement. :) – pacoverflow Jul 28 '15 at 20:04
• Ah well... That was much ado about nothing, then... – Kevin Rubin Jul 28 '15 at 20:14

I don't think this is what you're after, but it could look like part of one school of thought for the perfect barbecue:

add another one (second distinct Obj object: 'another', hashCode: 'one') to the block (static initialiser: 'block', also HashSet: reference to barbecue grids or the deliberate style of burn marks on the meat after cooking), turn it over once at the natural point, i.e. half way through cooking (e: base of natural logs, rotate by $\pi$: turn around), then just let it sit i.e. do nothing until it is done (empty brace = nop: do nothing , end of main(): 'done').

• But is this answer well done? – Mark N Jul 29 '15 at 14:52
• @MarkN Compared to the other answers so far, perhaps rare. – Lawrence Jul 30 '15 at 2:18