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

2011/6/3

What is the diference between "boolean" and "void"?

What is the diference between "boolean" and "void"?
MrCohen MrCohen

2011/6/3

#
I assume you are talking about return types, as in: private void myMethod () void means the method does not return anything. boolean is a variable type that can be used to hold the value "true" or "false" (it can be thought of as similar to a light switch - either on or off). These are the basics of methods, which is grade 11 curriculum in my region. You should probably find a tutorial on Java if you want a full understanding.
I am looking for a line of code that changes a boolean ( a for example ) that when it is clicked it changes from true to false and vice versa
Super_Hippo Super_Hippo

2014/9/8

#
1
if (Greenfoot.mouseClicked(this)) a = !a;
danpost danpost

2014/9/8

#
Since nobody actually mention anything about 'void', I will say this: 'void' is the absence of a data type; similar to how 'null' is the absence of an object. I do not know of any other use for 'void' other than as a return type in a method declaration statement.
You need to login to post a reply.