I’m trying to make a If else condition to check if a current data exists on the database using a JSON request on a java application consuming a Rest Webservice. So, I want to receive a boolean or make a condition to verify what i’m receiving (normally, null or true/false) There’s a way to transform this in a boolean to
Tag: if-statement
how to make code print Suspended instead of won
Code doesn’t output Suspended but outputs Won when the user inputs true. Can someone help explain what have I done wrong with this code, please? Answer You use = incorrectly. In your example, if(isSuspended = true) {} means: To not assigned but check, you should use == instead. or better: P.S. I think you also mixed up the if cases.
I can’t loop my code whenever condition fails. It just prints both blocks of code if the user input is true
I am a beginner at java and I want to loop this all over again but I don’t know how. I’ve tried a while loop but it doesn’t work really well and it prints both blocks of code. What should happen is when I type “quit, Quit, or QUIT”, it should terminate. What happens instead is that it also prints
Finding the longest word ArrayList /Java
I want to write a method which finds the longest String (word). The output should be the longest word in case of two words with the same lenght the output should be: “More than one longest word”. I used ArrayList and almost had a solution, but something goes wrong. The case is that I have a problem when two words
Implementing a printAnimals method
I am trying to implement a printAnimals() method that prints the ArrayList for dogs or prints the ArrayList for monkeys, or prints all animals whose training status is “in service” and whose is Not reserved, depending on the input you enter in the menu. I am trying to correctly write a for loop for both ArrayList that contains if statements,
Intent with multiple if statements
I am learning the concept of Intents and the application I am working on crashes when I try to go from any other intent that’s not “Arabica” intent, the intent object is fired on onItemSelectedListener on a spinner. I want to make it so that when the user selects the other options on the spinner it will execute that intent
Tic Tac Toe runs and functions completely, but after getting 3 in a row, another move has to be made for it to end [closed]
Closed. This question needs to be more focused. It is not currently accepting answers. Want to improve this question? Update the question so it focuses on one problem only by editing this post. Closed 1 year ago. Improve this question Is anyone of you able to find out why it loops around 1 extra time even though the while condition
Java Null check fails and code proceeds to if statement
I have an if condition within my code and I do not want my code to proceed into the if condition if the value of the variable is Null but for some reason, the condition passes and proceeds to the next part but the value of the field is NULL. I am not sure why this issue is happening. A
Switch Case In ActionPerformed?
Ive gone through some stack overflow questions and found this similar question. From what I understand using a switch statement in an actionPerformed method for this context will not work and an if-else statement is required. Is there a more efficient way to do this without having repetitive code? I’ve heard I could use Abstract Action to give multiple buttons
Java Contain method cannot find symbol
I am trying to only print strings containing the word “The” from a text file but the contain method does not seem to be working. Is there any other way to do this or fix the contain method? } Answer You’re calling contains on Scanner object, you should call it on the lines that you read from file, that’s the