0

WHEN I put void in this method.. it says "void type not allowed here" in my if statement.
but when I erase the void in my method.. it says error: invalid method declaration; return type required in the method...
what should I do?

public void setStop(int day , int hour , int minute , int second )
                 {
                    if (0 <= day )
                        daysStop = day;

                    else
                        daysStop = 0;


                    if (0 <= hour && hour < 24 )
                        hoursStop = hour;

                    else
                        hoursStop = 0;

                    if (0 <= minute && minute < 60)
                        minutesStop = minute;

                    else
                        minutesStop = 0;

                    if (0 <= second && second < 60 )
                        secondsStop = second;

                    else secondsStop = 0;
                 }







    /* IF STATEMENT  - part of a different method*/

    if (setStop ( daysStop, hoursStop, minutesStop, secondsStop) == true )

Edited by Johannady2

3
Contributors
2
Replies
3
Views
5 Years
Discussion Span
Last Post by NormR1
1

Line 26 closes the method definition, so the if statement is not in any method, which is illegal and has confused the compiler.

Votes + Comments
the if statement is inside a different method.. I didn't paste it here anymore because it's too long.
1

Also the if statement requires a boolean expression inside of the ()s; A method defined as void does not return a boolean value.

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.