If you can "convert" decimal number to binary, it means they are not numbers. All numbers a binary, did you know that?
"4 = 001" means that you create a string "001" which represent a binary literal of the number on the left side of '=' (this is not assignment, just some free written form of the example). The input data can be of numeric type, but then if cannot be "decimal" or "hexadecimal" or anything related to the base, but it could be also a string representing the number; it is not very important; you first need to get a number (of numeric type, not string) and then build a string out of it.
Now, the problem is really solved in one line. Or two. What you have written has little sense. You need to use bitwise operators. See this:
http://download.oracle.com/javase/tutorial/java/nutsandbolts/op3.html[
^].
I will leave the coding for your homework. You are supposed to do some homework if you want to understand at least something, aren't you?
—SA