Java Boolean toString() MethodThe toString() method of Java Boolean class returns a String illustration of this Boolean. If the defined object is true, the result returned is "true", otherwise false is returned. Syntax:Parameters:NA b - This is the Boolean argument to be converted. Return Value:The toString() method returns:
Example 1Test it NowOutput: Boolean value = true Hash Code for boolean value = 1231 String value = true Hash Code for String Value = 3569038 Example 2Output: Enter your percentage. 89 Congratulation! You have passed. Example 3Test it NowOutput: Your age is 9 years. Sorry! You are not an adult. You will be eligible after9year. Example 4Output: True/False:- 5 months have 30 days. Ans: true Answer is wrong. Because all 11 months (except Feb) have 30 days. Example 5Test it NowOutput: Error:(7, 23) java: boolean cannot be dereferenced Boolean is a primitive data type, its object can't be used to call Boolean class objects. 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