What does "method" mean?
I came across some code today that reads
public class SomeClass
{
int DEFAULT_INT = 5;
public static int SomeMethod()
{
return ~FooBar(DEFAULT_INT);
}
public static int SomeMethod(int i)
{
return ~FooBar(i);
}
public static int FooBar(i)
{
......
}
}
I haven't seen this before, and as far as I know its legal name ~ FooBar Does anyone know if "~" does something special?
Sorry, I have adjusted the code from the original post. I missed reading the FooBar method.
+3
source to share
2 answers
As stated above, this is a bitwise operator that changes every bit.
The method FooBar
returns int. Behind the scenes, it returns 32 bits, which would look something like this:
1110000001100 ..... // 32 characters.
Executing ~
on this int will return 0001111110011 .....
Another example:
~(101) = 010 ~(000) = 111
+2
source to share