Originally Posted by
melki0795
i think that listing a statement something like that all the way to F would be messy....
Here's a hint to an easier way:
char first = 'b';
char second = 'z';
System.out.println(first >= 'a' && first <= 'c');
System.out.println(second >= 'a' && second <= 'c');
--- Update ---
Originally Posted by
ChristopherLowe
Once again you are trying to use bitwise & for a logical statement.
Actually using a single ampersand is fine as long as you know the consequences. Run the following code.
class BooleanTest {
private boolean methodOne() {
System.out.println("Method one");
return false;
}
private boolean methodTwo() {
System.out.println("Method two");
return false;
}
public void run() {
if(methodOne() && methodTwo()) {
System.out.println("Foo");
}
System.out.println();
if(methodOne() & methodTwo()) {
System.out.println("Foo");
}
}
public static void main(String[] args) {
new BooleanTest().run();
}
}