answersLogoWhite

0


Best Answer

no, you cant. it only works on string

User Avatar

Wiki User

11y ago
This answer is:
User Avatar

Add your answer:

Earn +20 pts
Q: Can you compare a boolean to an integer?
Write your answer...
Submit
Still have questions?
magnify glass
imp
Related questions

Can you do a boolean test on integer in java?

No


How do you convert an integer to Boolean array list in java?

You cannot. An Integer is a numeric value whereas a boolean array list is a collection of a number of true or false values. So, you cannot convert either into the other


What is Boolean operator in c language?

A Boolean operator is any operator that returns true or false. False is typically denoted by the integer value 0 while all non-zero values equate to true. The less-than operator (<) is an example of a Boolean operator.


What data type is the is Yes or No?

In Java, that would be called "boolean". In other languages it may have different names, for example, "logical". In C, there is no true boolean data type, so people just use integer and if you want the integer to be true, you set it to 1 and if you want it to be false, you set it to 0.


What are Integer Boolean and Double wrapper classes?

In Java an integer and a double are "primitive" data types.When dealing with functions, often you want to do more than send an "int" or a "double"'s VALE, you wish to send a REFERENCE of a number type to a function so that you can operate on that number type. What you can do is create a new Integer, Boolean, or Double, and send it to the function. This creates a "CLASS" that acts as an Integer (or whatever you chose).Eg. You want a function that takes in a number variable, and adds two to it, and returns NOTHING. You cannot send a normal "int", because that integer cannot be "referenced" to after the function call. You would create a new Integer Object from the Integer Class, and insert that new object to the function.Integer four = new Integer(4); // Makes a new Integer named "four" with the value 4.There is a wrapper class for every primitive in Java. For instance, the wrapper class for int is Integer, the class for float is Float, and so on. Remember that the primitive name is simply the lowercase name of the wrapper except for char, which maps to Character, and int, which maps to Integer.The Wrapper classes for each of the primitive types is as follows:1. boolean - Boolean2. byte - Byte3. char - Character4. double - Double5. float - Float6. int - Integer7. long - Long8. short - ShortA point to note here is that, the wrapper classes for numeric primitives have the capability to convert any valid number in string format into its corresponding primitive object. For ex: "10" can be converted into an Integer by using the below lineInteger intVal = new Integer("10");I can do the same for all numeric types like long, short etc. But, if I pass an invalid value I will get a "NumberFormatException" Ex:Integer intVal = new Integer("Haha");The Wrapper ConstructorsAll of the wrapper classes except Character provide two constructors: one that takes a primitive of the type being constructed, and one that takes a String representation of the type being constructed-for exampleInteger i1 = new Integer(42);Integer i2 = new Integer("42");orFloat f1 = new Float(3.14f);Float f2 = new Float("3.14f");The Character class provides only one constructor, which takes a char as an argument-for exampleCharacter c1 = new Character('c');The constructors for the Boolean wrapper take either a boolean value true or false, or a String. If the String's case-insensitive value is "true" the Boolean will be true-any other value will equate to any other value will equate to false. Until Java 5, a Boolean object couldn't be used as an expression in a boolean test-for instanceBoolean b = new Boolean("false");if (b) // won't compile, using Java 1.4 or earlierAs of Java 5, a Boolean object can be used in a boolean test, because the compiler will automatically "unbox" the Boolean to a boolean.


Does HTML allow you to declare integer real string and boolean variables?

HTML is not a programming language and as such does not allow you to declare variables.


What are four Boolean operators?

Depends on the computer language, the Boolean operators may have different looks, but all the basic ones should be in place:Equality (Equals(), ==, IsTrue, IsFalse), to compare 2 boolean valuesNot (~, !, .NOT. ), negation or compliment. That is, !True TrueAnd (&, &&, .AND.), the intersection.Or (|, , .OR.), the union


Difference between relational and logical operators?

Logical operators don't Compare values they combine Boolean values and produce a Boolean result. Examples of logical operators are && (and), , (or), ! (not). If you have two Boolean values and you combined them with the && operator the result will be (TRUE) only if both values were (TRUE). Relational operators compare two values and produce a Boolean result. Most of the time we use logical operators to combine the results of two or more comparison expressions that use relational operators.


How do you compare decimals when the digits to the left of the decimal point are not 0?

You compare the integer parts first.


What are different types of data called?

Some different types of data are real-valued, integer, or Boolean. Boolean Data is data that represents true or false statements Fixed point data types are convenient for representing monetary values


What has the author Fred Glover written?

Fred Glover has written: 'Equivalence of Boolean constrained transportation problems to transportation problems' -- subject(s): Algebra, Boolean, Boolean Algebra, Mathematical models, Transportation 'Optimal weighted ancestry relationships' -- subject(s): Mathematical models, Pottery dating, Algorithms, Cemeteries 'Manipulating the branch and bound tree' -- subject(s): Branch and bound algorithms, Integer programming 'Surrogate constraint duality in mathematical programming' -- subject(s): Programming (Mathematics) 'Play Showtime' 'Neglected heuristics in integer programming / by Fred Glover' -- subject(s): Integer programming


Is String class a final class?

The core classes in the java.lang.* package (e.g. String, Integer, double, Boolean, etc.) are all declared final.