+ 2

In declaring your own method in java can you add ' public' in the declaration

17th Jan 2018, 4:59 PM
Judith
5 Respuestas
+ 8
Yes, you can add public in the declaration like: public returnType myMethod() { return value; }
17th Jan 2018, 5:05 PM
Cool Codin
Cool Codin - avatar
+ 3
yes you can. depending on how nd were u want you method to b accessible from.
17th Jan 2018, 7:24 PM
Rozzae
Rozzae - avatar
+ 2
Yes the "public" modifier states that the method can be called from outside the class as opposed to private which prevents a function being called from outside the class.
17th Jan 2018, 6:01 PM
josh mizzi
josh mizzi - avatar
+ 1
yes...the 'public' keyword is used to make that method accessible to to all other java classes in your project
17th Jan 2018, 5:10 PM
gabriel ibenye
+ 1
yes public can be added public void myMethod(){ --- - - - - statements }
17th Jan 2018, 5:34 PM
gabriel ibenye