Help: boolean expressions

This might be a dumb question but Im new to Java and i have no idea what to do.

I'm trying to make the line (! i || q) && (i || ! q) to work but keep on getting a error saying :

G:\CSCI 120\CW\CW_8.java:23: operator ! cannot be applied to int

System.out.println(i + " " + q + " " + (!i || q) && (i || !q) + " ");

^

G:\CSCI 120\CW\CW_8.java:23: operator ! cannot be applied to int

System.out.println(i + " " + q + " " + (!i || q) && (i || !q) + " ");

^

G:\CSCI 120\CW\CW_8.java:23: operator && cannot be applied to java.lang.String,java.lang.String

System.out.println(i + " " + q + " " + (!i || q) && (i || !q) + " ");

^

how can i fix this?

this is the code i hav so far:

public class CW_8

{

public static void main(String[] args)

{

System.out.println("i" + " " + "q" + " " + "((!i || q) && (i || !q)");

{

int i;

int q;

for (i=0; i <= 1; i++)

for (q=0; q <= 1; q++)

{

System.out.println(i + " " + q + " " + (! i || q) && (i || ! q) + " ");

}

}

}

[1180 byte] By [USAF0910a] at [2007-11-26 21:38:17]
# 1
Use boolean. In Java, the numbers (int etc) 0 and 1 cannot be treated like booleans.Edit: More correctly, you cant ! (negate) them. You CAN do bitwise & and | with ints.
TuringPesta at 2007-7-10 3:21:09 > top of Java-index,Java Essentials,Java Programming...
# 2
Might seem strange, but the reason you're getting that message is that the operator ! cannot be applied to an int. :-)You have to use i==0 instead of !i in java.
kevjavaa at 2007-7-10 3:21:10 > top of Java-index,Java Essentials,Java Programming...
# 3

Note: ignore the 1 bit assertion its most likely a byte in memory.

http://www.cafeaulait.org/course/week2/02.html

boolean

1-bit. May take on the values true and false only.

true and false are defined constants of the language and are not the same as True and False, TRUE and FALSE, zero and nonzero, 1 and 0 or any other numeric value. Booleans may not be cast into any other type of variable nor may any other variable be cast into a boolean.

TuringPesta at 2007-7-10 3:21:10 > top of Java-index,Java Essentials,Java Programming...
# 4
Actually variables and fields are allocated in 4 byte slots, so booleans take 4 bytes except when packed into an array.
malcolmmca at 2007-7-10 3:21:10 > top of Java-index,Java Essentials,Java Programming...