+ 1

I used an OR operator in my if-else statement, I put two integers in the condition separated by ||. Syntax error shows..Why??

So here goes: void getdata(int x, int y) if (x=1 || y=1) { System.out.println("xx") } It is showing a syntax error that this operator does not support int,int..

24th Nov 2016, 3:35 PM
Aniket
3 Answers
+ 2
you can not use that either assign values before and use it between x and y or do this if you wanted this (x==1||y==1) or simply use x or y as Aditya said you cannot call the value and assign it in same place. I don't know if there was reason for that but you can increment or decrement before doing so or make a function that toggles them and use that function if you want to make them true
24th Nov 2016, 5:18 PM
Sandeep Chatterjee
+ 1
Thnx Sandeep, the == operator did the trick
26th Nov 2016, 10:46 AM
Aniket
0
operators
27th Nov 2016, 10:52 AM
sachin pagariya