• Register
1 vote
26 views

Problem:

Let me put it as sim as I can. I have an if statement in my code and it returns a value. Since IF is a boolean statement it should return value whether it’s true or false. So, in my program when a method tests an argument and returns a true or false value, it should return. That all I am trying to say. I already wrote a code attaching below:

public boolean isValid() {
   boolean examine;
   int var = 10;

   if (var > 5){
      examine = true;
   } else {
      examine = false;
   }

 return examine;

Now, I want to use my isValid() method as a parameter in a different method inside an IF statement. How should I do that?
Any kind of help is appreciated by my side.
Thanks.

12 7 7
15,250 points

1 Answer

0 votes

Solution:

As per your question, I summed up my understanding that you wanted to pass the isValid() in an IF statement.

Just put the method inside the IF statement, like this:

if(isValid()) {
    // Do Something
} else {
    // Do Something
}

Here the IF statement will return a value whether it is true or false.
That’s all you have to do. Thanks

13 9 6
94,240 points

Related questions

1 vote
1 answer 13 views
13 views
Problem: I am new in python programming an I have been learning for this some days. As a newbee I am still learning and and I am cofused about some things. My question is “In an if/else statement, if the boolean expression is always false?”
asked Apr 3 LizzyM 6.1k points
0 votes
1 answer 15 views
15 views
Problem: I am very new to the Java. I am currently trying to understand the if statements in java. I have one doubt as follows if(a && b || c || d || e) then whether it will check (a && b) if a and b must be always true then only will it allow inside ... a && e))here if any of the conditions are true then will it allow inside ? Please guide me in solving my doubts related to if statements in java.
asked Jul 29 Raphael Pacheco 4.9k points
1 vote
1 answer 21 views
21 views
Problem: I wrote a code to check if a value is an integer in python but the code gives me the following error message: Traceback (most recent call last): File "int.py", line 10, in <module> if __input__ == "__main__" : NameError: name '__input__' is not defined ... Why am i getting this error message and what is the problem in my program. Please help me to solve out this error. Thanks in advance.
asked May 14 samhaz 5k points
0 votes
1 answer 10 views
10 views
Problem: I want to check if the very specific value already exists in the database. I am currently accessing database from the java standalone app using the JDBC my queries for inserting records into the db are working so my setup and the connection are perfectly fine. ... near 'd-f05708071f8f' at line 1 But if I attempt to execute above command in the MySQL command line then it works properly.
asked Aug 3 Raphael Pacheco 4.9k points
0 votes
1 answer 11 views
11 views
Problem: Hi! I want to check whether an array is empty or null in Java. Any guidance would be appreciated.
asked Oct 12 Sheeza 2.3k points