Why is the logic for the boolean to return false instead of true?
Can someone please explain this?
In my head you would have the final return as true because if the above condition is false, it would return a false?
Someone please explain the logic
package com.codegym.task.task06.task0610;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.Scanner;
/*
ConsoleReader class
*/
public class ConsoleReader {
public static String readString() throws Exception {
//write your code here
BufferedReader stringReader = new BufferedReader(new InputStreamReader(System.in));
String stringInput = stringReader.readLine();
return stringInput;
}
public static int readInt() throws Exception {
//write your code here
Scanner intScanner = new Scanner(System.in);
int intInput = intScanner.nextInt();
return intInput;
}
public static double readDouble() throws Exception {
//write your code here
Scanner doubleScanner = new Scanner(System.in);
double doubleInput = doubleScanner.nextDouble();
return doubleInput;
}
public static boolean readBoolean() throws Exception {
//write your code here
BufferedReader booleanReader = new BufferedReader(new InputStreamReader(System.in));
String booleanInput = booleanReader.readLine();
boolean b;
if ("true".equals(booleanInput)){
b = true;
}
else if ("false".equals(booleanInput)){
b = false;
}
return true;
}
public static void main(String[] args) {
}
}