• Register
1 vote
29 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

Please log in or register to answer this question.

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 19 views
19 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, 2020 LizzyM 6.1k points
0 votes
1 answer 12 views
12 views
Problem: Hello programmers! I am learning to program, and I just got a little confused about boolean values and logical operators. I tried to run the following program: #include<iostream> using namespace std; int main() { bool check = false && true || true; ... program, I got the following output: Condition evaluated to true I am so confused about how this condition evaluates to true. Any help?
asked Dec 18, 2020 Code Learner 5.3k points
0 votes
1 answer 15 views
15 views
Problem: Hello all, I just recently started learning Java. In today&rsquo;s class, we learned about ternary operator and my teacher gave me an assignment in which I have to convert given if-else statement using ternary operator: if(number1<number2 && number1 < number3 ... out the smallest number"); I am unable to figure out how to change these statements using ternary operators. Can anybody help?
asked Nov 30, 2020 Code Learner 5.3k points
0 votes
1 answer 12 views
12 views
Problem: Hi! I am a beginner and while attempting an exam of Java, I came across a multiple choice question which was as follows: In a project, 2 classes must contain main method (True/False) I chose False because as far as I know, if two or more classes have main ... . I want to know the correct answer with proper reason. If any of you can tell me the correct answer, I would be grateful. Thanks
asked Nov 29, 2020 Code Learner 5.3k points
0 votes
1 answer 37 views
37 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, 2020 Raphael Pacheco 4.9k points
0 votes
1 answer 20 views
20 views
Problem: I want to know the difference between | and ||, & and && in C++. What is the difference if I use the &lsquo;if&rsquo; condition as if(a == b || a == c) or if(a == b | a == c)? Please elaborate. Thanks
asked Oct 21, 2020 Code Learner 5.3k points
0 votes
1 answer 16 views
16 views
Problem: Hi there! I am working with a textbox in C# and I want to define multiple restrictions on this textbox through if statement. If I use nested ifs, my program becomes bulky. I want to keep my program as compact as possible. Attaching my code below. Please guide how I ... is " + Convert.ToInt32(nameTextBox.Text); } } I want to check if the text in the textbox is a number from 1 &ndash; 10.
asked Oct 15, 2020 Code Learner 5.3k points
1 vote
1 answer 39 views
39 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, 2020 samhaz 5k points
0 votes
1 answer 16 views
16 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, 2020 Raphael Pacheco 4.9k points
0 votes
1 answer 31 views
31 views
Problem : My function accepts the two arrays of integers and returns true if below conditions are met 1. Arrays have the same length and 2. Each m.element should be less than each n.element of the same index All my test cases are passing except when int[] m = {1, 2, 3} and int[] n = ... = (m[j] < n[j]); for (j = 0; j <= m.length - 1; j++) {} return (sameLength && digitDifference); }
asked Dec 3, 2019 alecxe 7.5k points