Skip to Main Content

Java Programming

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

Help: boolean expressions

807606Mar 14 2007 — edited Mar 14 2007
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) + " ");
}
}
}
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Apr 11 2007
Added on Mar 14 2007
4 comments
262 views