jeudi 7 avril 2016

Boolean If statement only returning outside [duplicate]

This question already has an answer here:

public static boolean stringToBoolean (String horv) { 
    if (horv == "H") {
        return true;
    } if (horv == "V") {
        return false;
    } else {
        return true;
    }

This is a small part of a program I am creating. The program is reading from a file and inputting the data into an array. For this part it is reading what will either be a "H" or "V" from the file and converting it to a boolean value. The problem is when I run the program I am only getting true for every value, even the ones that have a "V" as their variable.

Aucun commentaire:

Enregistrer un commentaire