Reputation: 21
In java language, how could I change the condition so that it returns as false
instead of true
?
char table[][] = {{}};
return (table != null && table.length > 0);
Upvotes: 1
Views: 479
Reputation:
The universal way to reverse any condition is to use a round brackets and an exclamation mark !(...)
. If this condition returns true
:
return table != null && table.length > 0;
then this condition returns false
:
return !(table != null && table.length > 0);
Upvotes: 0
Reputation: 8724
The first question you need to answer to yourself is "What is an empty 2d array?". As you have it now, that is either an uninitialized array or an initialized array that contains no elements.
Instead, you have initialized a 2d array to be an array holding an empty array with char table[][] = {{}};
char table[][] = {{}};
System.out.println(table.length);
would print 1 because the element at index 0 is an array of length 0.
Upvotes: 3