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;

                        daysStop = 0;

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

                        hoursStop = 0;

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

                        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 )

Recommended Answers

All 2 Replies

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

commented: the if statement is inside a different method.. I didn't paste it here anymore because it's too long. +0

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

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.