The moose likes Beginning Java and the fly likes modolo operator on RR3 Big Moose Saloon
  Search | Java FAQ | Recent Topics
Register / Login


Win a copy of The Mikado Method this week in the Agile and other Processes forum!
JavaRanch » Java Forums » Java » Beginning Java
Reply Bookmark "modolo operator on RR3" Watch "modolo operator on RR3" New topic
Author

modolo operator on RR3

Jimmy Bonds
Ranch Hand

Joined: Jun 05, 2001
Posts: 38
class LeapYear
{
int year;

int getY(int i)
{
year=i;
return year;
}

void leepY()
{
if((year%100=0)|(year%400=0))
{
System.out.println("Not a Leap Year!");
}
else if(year%4=0)
{
System.out.println("Leap Year!!");
}
else
{
System.out.println("not a Leap Year!");
}
}
}
Hi all,
When I run the preceeding code I get a compile error saying-
"invalid left hand side of assignment:
if((year%100=0)|(year%400=0))"
^
It's my understanding that the expression to be evaluated should be on the left, such as: 10%3=1.
Where 10 is the expression.
Please set me straight!

Junilu Lacar
Bartender

Joined: Feb 26, 2001
Posts: 4118
    
    2

Use "==" for comparing two things for equality. "=" assigns the value on the right side to whatever is on the left side.
Junilu


Junilu - [How to Ask Questions] [How to Answer Questions] [MiH]
Jimmy Bonds
Ranch Hand

Joined: Jun 05, 2001
Posts: 38
DOH!!!

 
I agree. Here's the link: http://ej-technologies/jprofiler - if it wasn't for jprofiler, we would need to run our stuff on 16 servers instead of 3.
 
subject: modolo operator on RR3
 
Similar Threads
please verify this code
enter a value
first java am stuck
Leap Year program
unreachable statement error