Java Boolean valueOf() MethodThe valueof() method of Java Boolean class returns a Boolean instance corresponding to the defined Boolean or to the defined String. This method returns Boolean 'true' if the defined Boolean value or String value is true, and returns the Boolean 'false' if the defined Boolean or String value is false. Syntax:Parameters:b - This is a Boolean argument to be passed s - This is the string argument to be passed. Return Value:The valueOf() method returns a Boolean instance corresponding to 'b' or to String 's'.
Example 1Test it NowOutput: valueOf() method will return = true valueOf() method will return = false Example 2Output: Enter the number whose table you want to print : 19 Table of 19 : 19 * 1 = 19 19 * 2 = 38 19 * 3 = 57 19 * 4 = 76 19 * 5 = 95 19 * 6 = 114 19 * 7 = 133 19 * 8 = 152 19 * 9 = 171 19 * 10 = 190 Example 3Output: Enter you age 78 You are an adult. You are eligible to vote. Example 4Output: True/False: Q. TalMahal is located in Delhi. Ans false Incorrect. Because TajMahal is located in Agra. Example 5Test it NowOutput: 1. Boolean value for True is true 2. Boolean value for false is false 3. Boolean value for hwhfjh is false Next TopicJava Boolean |
We provides tutorials and interview questions of all technology like java tutorial, android, java frameworks
G-13, 2nd Floor, Sec-3, Noida, UP, 201301, India