Can anyone explain to me how accessModifier, returnType, and returnValue work? and also how does "return" work also?
thanks for any help
Can anyone explain to me how accessModifier, returnType, and returnValue work? and also how does "return" work also?
thanks for any help
private is an example of an access modifier. It means that only code within that class can access the function. Others exist: public will allow anybody to access the function/variable, while protected will allow code in that class or any class that extends that class to access the function/variable. The green int declares that this function will return an int. This is necessary because Java is a strongly- and statically-typed language, so the compiler must know the types of any potential data in advance. return is the value returned by the function when called; this must be of the type declared as the function's return value. If we were to do, in some other code:Code:private int returnFive() { return 5; }... the int five would hold the value 5.Code:int five = returnFive();
Twey | I understand English | 日本語が分かります | mi jimpe fi le jbobau | mi esperanton komprenas | je comprends français | entiendo español | tôi ít hiểu tiếng Việt | ich verstehe ein bisschen Deutsch | beware XHTML | common coding mistakes | tutorials | various stuff | argh PHP!
The returnType and returnValue must be the same type right?
Return type and return value, please. They're not keywords, you don't need to put them in camelCase
Yes.
Twey | I understand English | 日本語が分かります | mi jimpe fi le jbobau | mi esperanton komprenas | je comprends français | entiendo español | tôi ít hiểu tiếng Việt | ich verstehe ein bisschen Deutsch | beware XHTML | common coding mistakes | tutorials | various stuff | argh PHP!
Ok thanks.
can the access modifier be left out? or will i get some type of error? also what do the the access modifiers specifically mean?
Yes, it will default to protected.
Originally Posted by myself
Twey | I understand English | 日本語が分かります | mi jimpe fi le jbobau | mi esperanton komprenas | je comprends français | entiendo español | tôi ít hiểu tiếng Việt | ich verstehe ein bisschen Deutsch | beware XHTML | common coding mistakes | tutorials | various stuff | argh PHP!
thanks. i knew i had seen it somewhere. sorry to ask again.
THANKS
Bookmarks