-1

Possible Duplicate:
What does this tilde mean?

I am using IntelliJ and found that it can re-factor my code of the following

Handle<String> handle = new Handler<String>() {}

to Handler<String> handler = new Handler<~>() {}

what's the meaning of ~ in the above?

Community
  • 1
  • 1
Adam Lee
  • 24,710
  • 51
  • 156
  • 236

3 Answers3

2

This is a folding of the type arguments used by IntelliJ IDEA. It is a shorthand syntax for your viewing pleasure, not valid Java syntax.

Nathan Ryan
  • 12,893
  • 4
  • 26
  • 37
1

In Java Handler handler = new Handler<~>() {} means syntax error, nothing else

Evgeniy Dorofeev
  • 133,369
  • 30
  • 199
  • 275
0
Handler<String> handler = new Handler<~>() {};

will not compile it has no meaning (except for eye-catching effect).

~ is Unary operator and it means Binary Ones Complement Operator it has the effect of 'flipping' bits. (~A ) will give -60 which is 1100 0011

EDIT

According to @Jan Dvorak, The question is incorrect in stating the IDE suggested this as a refactor.

aviad
  • 8,229
  • 9
  • 50
  • 98