Skip to content

Why doesn’t my if statement work with (red || green || blue) > 255

here’s my code: I’m having problems in this line: bad operand types for binary operator ||. Any ideas how to fix it? My code is very simple so I believe I don’t have to explain anything. I just don’t understand why I can’t check if integer is greater than 255 for e.g. Thanks on a…

Java, comparing a Linked List to an Array

Working on a Java program that will read in two different passages, convert both strings to arrays of strings for each word, and then String One to a linked list, which will promptly be sorted into alphabetical order. After the list has been sorted, I get confused. I have a for loop written to get the length …

What state is a sleeping thread in?

I’m looking for verification/arguments on the following: A thread is in exactly one of the 5 (+1 — 2 for WAITING) states at any point of time. Suppose a thread T calls Thread.sleep(3000); and thus puts itself into sleep for 3 secs. Which state is it in during those 3 secs? It’s clearly start…

Convert Java object to XML string

Yes, yes I know that lots of questions were asked about this topic. But I still cannot find the solution to my problem. I have a property annotated Java object. For example Customer, like in this example. And I want a String representation of it. Google reccomends using JAXB for such purposes. But in all exam…