Can't compile simple Java code  
Author Message
JS





PostPosted: 2004-11-24 20:51:00 Top

java-programmer, Can't compile simple Java code 1 class DecimalToBinary{
2 public static void main(String[] y){
3 int dec = new Integer(y[0]).intValue();
4 if (dec/32 = 0)
5 System.out.println(0 + (dec % 32) / 16);
6 else System.out.println(1);


}}

When I try to compile the above code I get an error on line 4:

Error: unexpected type
required: variable
found : value


What is wrong??


Mvh
Johs


 
JS





PostPosted: 2004-11-24 20:52:00 Top

java-programmer >> Can't compile simple Java code 1 class DecimalToBinary{
2 public static void main(String[] y){
3 int dec = new Integer(y[0]).intValue();
4 if (dec/32 = 0)
5 System.out.println(0 + (dec % 32) / 16);
6 else System.out.println(1);


}}

When I try to compile the above code I get an error on line 4:

Error: unexpected type
required: variable
found : value


What is wrong??


Js


 
John





PostPosted: 2004-11-24 20:55:00 Top

java-programmer >> Can't compile simple Java code JS wrote:
> 1 class DecimalToBinary{
> 2 public static void main(String[] y){
> 3 int dec = new Integer(y[0]).intValue();
> 4 if (dec/32 = 0)
> 5 System.out.println(0 + (dec % 32) / 16);
> 6 else System.out.println(1);
>
>
> }}
>
> When I try to compile the above code I get an error on line 4:
>
> Error: unexpected type
> required: variable
> found : value
>
>
> What is wrong??
>
>
> Mvh
> Johs
>
>

use c.l.j.help for this sort of thing please.

You need to use == instead of = on line 4. "==" compares and "=" assigns.

John
 
 
Michael Borgwardt





PostPosted: 2004-11-24 20:56:00 Top

java-programmer >> Can't compile simple Java code JS wrote:

> 1 class DecimalToBinary{
> 2 public static void main(String[] y){
> 3 int dec = new Integer(y[0]).intValue();
> 4 if (dec/32 = 0)
> 5 System.out.println(0 + (dec % 32) / 16);
> 6 else System.out.println(1);
>
> }}
>
> When I try to compile the above code I get an error on line 4:
>
> Error: unexpected type
> required: variable
> found : value
>
>
> What is wrong??

You're trying to assign the value 0 to the expression dec/32, which
is also a value. That's not possible. You probably meant
"dec/32 == 0" (a comparison), not "dec/32 = 0" (an assignment).
 
 
DJY





PostPosted: 2004-11-24 20:58:00 Top

java-programmer >> Can't compile simple Java code Use comparison == not assignment =

"JS" <email***@***.com> wrote in message news:co202r$lfv$email***@***.com...
>1 class DecimalToBinary{
> 2 public static void main(String[] y){
> 3 int dec = new Integer(y[0]).intValue();
> 4 if (dec/32 = 0)
> 5 System.out.println(0 + (dec % 32) / 16);
> 6 else System.out.println(1);
>
>
> }}
>
> When I try to compile the above code I get an error on line 4:
>
> Error: unexpected type
> required: variable
> found : value
>
>
> What is wrong??
>
>
> Js
>
>