This site requires JavaScript, please enable it in your browser!
Greenfoot back
Gabe1098
Gabe1098 wrote ...

2021/6/22

Boolean and Return

Gabe1098 Gabe1098

2021/6/22

#
hello I am very new to greenfoot and I have been doing discussions a lot lately so can you please do a simple explanation about boolean and return
danpost danpost

2021/6/22

#
Gabe1098 wrote...
hello I am very new to greenfoot and I have been doing discussions a lot lately so can you please do a simple explanation about boolean and return
Boolean: the boolean data type has only two possible values: true and false. Use this data type for simple flags that track true/false conditions. Return: the return statement is used to immediately exit a method. In a method whose return type is declared void, it is used to force an immediate exit so that the following lines of code in the method do not execute. In a method with a non-void return type, the return statement MUST be used to exit the method AND must be followed by the value to return, which must be of that declared return type. Note that for Object types, null can be a returned value.
Gabe1098 Gabe1098

2021/6/22

#
danpost wrote...
Gabe1098 wrote...
hello I am very new to greenfoot and I have been doing discussions a lot lately so can you please do a simple explanation about boolean and return
Boolean: the boolean data type has only two possible values: true and false. Use this data type for simple flags that track true/false conditions. Return: the return statement is used to immediately exit a method. In a method whose return type is declared void, it is used to force an immediate exit so that the following lines of code in the method do not execute. In a method with a non-void return type, the return statement MUST be used to exit the method AND must be followed by the value to return, which must be of that declared return type. Note that for Object types, null can be a returned value.
Could you show me an example of these?
You need to login to post a reply.