I'm trying to write a code that converts a number to binary, and this is what I wrote. It gives me couple of errors in Eclipse, which I don't understand.
What's wrong with that? Any other suggestions? I'd like to learn and hear for any comments for fixing it. Thank you.
public class NumberConverte {
public static void main(String[] args) {
int i = Integer.parseInt(args);
public static void Binary(int int1){
System.out.println(int1 + "in binary is");
do {
System.out.println(i mod 2);
} while (int1>0);
}
}
}
The error messages:
- The method
parseInt(String)
in the type Integer
is not applicable for the arguments (String[]
)
- Multiple markers at this line
- Syntax error on token "
(
", ; expected
- Syntax error on token "
)
", ; expected
void
is an invalid type for the variable Binary
- Multiple markers at this line
- Syntax error on token "mod", invalid AssignmentOperator
- Syntax error on token "mod", invalid AssignmentOperator.
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…