[4317] in java-interest
RE: My oh my not again
daemon@ATHENA.MIT.EDU (John Mignault)
Sat Dec 16 01:16:30 1995
From: John Mignault <jbm@panix.com>
To: "java-interest-digest@java.sun.com"
<java-interest-digest@java.sun.com>
Date: Fri, 15 Dec 1995 22:03:18 -0500
----------
>what is wrong with this code???
>myrect.java:43: Incompatible type for if. Can't convert int to boolean.
> if(args.length = 2) {
^
>myrect.java:43: Invalid left hand side of assignment.
> if(args.length = 2) {
^
I assume you're trying to test for equality here, and what you're actually doing is
trying to assign the value 2 to args.length. The "Invalid left hand side of assignment"
error is a clue to the mistake. This should be
if(args.length == 2) {
^
The equality operator is ==, not =.
The reason you get the first error message is that the expression given to if has to
resolve to a boolean value, and here it would resolve to an integer (if
it'd let you make the assignment.)
>myrect.java:44: Class Interger not found in void main(java.lang.String[]).
> int w = Interger.valueOf(args[0]).intValue();
^
>myrect.java:45: Class Interger not found in void main(java.lang.String[]).
> int h = Interger.valueOf(args[1]).intValue();
^
>I know if I clear up line 43 then errors on 44 and 45 will go away
Well, no. This error has nothing to do with the previous one. The class name is spelled
"Integer," not "Interger."
>Thanks once again everyone....
--John Mignault
-
This message was sent to the java-interest mailing list
Info: send 'help' to java-interest-request@java.sun.com