Java Program to convert integer to boolean Last Updated : 02 Jan, 2020 Summarize Comments Improve Suggest changes Share Like Article Like Report Given a integer value, the task is to convert this integer value into a boolean value in Java. Examples: Input: int = 1 Output: true Input: int = 0 Output: false Approach: Get the boolean value to be converted. Check if boolean value is true or false If the integer value is greater than equal to 1, set the boolean value as true. Else if the integer value is greater than 1, set the boolean value as false. Example 1: Java // Java Program to convert integer to boolean public class GFG { public static void main(String[] args) { // The integer value int intValue = 1; // The expected boolean value boolean boolValue; // Check if it's greater than equal to 1 if (intValue >= 1) { boolValue = true; } else { boolValue = false; } // Print the expected integer value System.out.println( intValue + " after converting into boolean = " + boolValue); } } Output: 1 after converting into boolean = true Example 2: Java // Java Program to convert integer to boolean public class GFG { public static void main(String[] args) { // The integer value int intValue = 0; // The expected boolean value boolean boolValue; // Check if it's greater than equal to 1 if (intValue >= 1) { boolValue = true; } else { boolValue = false; } // Print the expected integer value System.out.println( intValue + " after converting into boolean = " + boolValue); } } Output: 0 after converting into boolean = false Comment More infoAdvertise with us Next Article Java Program to convert boolean to integer C code_r Follow Improve Article Tags : Java Java Programs Practice Tags : Java Similar Reads Java Program to convert boolean to integer Given a boolean value, the task is to convert this boolean value into an integer value in Java. Examples: Input: boolean = true Output: 1 Input: boolean = false Output: 0 Approach: Get the boolean value to be converted.Check if boolean value is true or falseIf the boolean value is true, set the inte 2 min read Java Program to Convert Char to Int Given a char value, and our task is to convert it into an int value in Java. We can convert a Character to its equivalent Integer in different ways, which are covered in this article.Examples of Conversion from Char to Int:Input : ch = '3'Output : 3Input : ch = '9'Output : 9The char data type is a s 4 min read Java Program to Convert String to boolean In Java, to convert a string to a Boolean, we can use Boolean.parseBoolean(string) to convert a string to a primitive Boolean, or Boolean.valueOf(string) to convert it to a Boolean object. The Boolean data type only holds two possible values which are true and false. If the string equals "true" (ign 3 min read Java Program to Convert Boolean to String In Java programming, you might come across the need to convert a simple "true" or "false" boolean value into a String. It may seem like a challenging task, but fear not! In this article, You will explore some methods to convert a boolean value to a string in Java Method for Boolean to String Convers 4 min read Java Program to Convert Integer Values into Binary Given an integer in Java, your task is to write a Java program to convert this given integer into a binary number. Example: Input: = 45 Output: = 101101 Input: = 32 Output: = 100000 Integers: Integers are numbers whose base value is 10. The Integer or int data type is a 32-bit signed twoâs complemen 4 min read Java Program to Convert Int to Double Java data types can be categorized as primitive and non-primitive. Primitive data types contain a single value, whereas non-primitive data types contain an address of the variable value. Java supports 7 primitive data types - boolean, byte, char, short, int, long, float, and double. These data types 4 min read Like