• Register
1 vote


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.

12 7 7
15,250 points

Please log in or register to answer this question.

1 Answer

0 votes


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 25 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 305 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 9.2k points
0 votes
1 answer 42 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 9.2k points
0 votes
1 answer 3 views
Problem: I&rsquo;m recently coursing C. But i have some issue. I want to know... What is a concise way to write an if statement with more than many || and && in C? I want to only execute a printf statement if a either 1,2,4 or 6 AND b = 8 and c = 10, can I put all these ... = 1||2||4||6) && b == 8 && c == 10) //do something This doesn't seem to work&hellip; Please help me to fix this. Thanks.
asked Mar 15 Shovo210 13.8k points
0 votes
1 answer 130 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 9.2k points
0 votes
1 answer 24 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 9.2k points
0 votes
1 answer 1 view
1 view
Problem: This question raised a very interesting point; there seems to be a contradiction in the Oracle documentation on whether it's possible for %NOTFOUND to be null after a fetch. Is it?
asked 4 days ago ummesalma 25.2k points
0 votes
1 answer 66 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 61 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 9.2k points
0 votes
1 answer 3 views
Problem: As I mentioned in my previous query, I'm having difficulties with my learning; I've tried searching the web but haven't been able to find adequate information; could you assist me in continuing my project?
asked Mar 30 tuhin1 48.9k points