Questions tagged [public-method]

A public method is a method declaration that allows access from other classes external to the current class.

A public method is a method declaration that allows access from other classes external to the current class. Public methods are used in many Object-Oriented programming languages including Java, C#, and Objective-C

From http://www.javabeginner.com/learn-java/introduction-to-java-access-modifiers

Fields, methods and constructors declared public (least restrictive) within a public class are visible to any class in the Java program, whether these classes are in the same package or in another package.

184 questions
4
votes
4 answers

How to exclude deprecated public methods from Javadoc?

I would like to generate javadoc for my classes. The 'generate Javadoc' command gives me an option to create Javadoc for members with visibility Private/Package/Protected/Public. But there are some public methods I don't want to be included in the…
snakile
  • 52,936
  • 62
  • 169
  • 241
4
votes
4 answers

Getting “private method” in a “public function” class using CoffeeScript

I'm doing a series of tests with classes and CoffeeScript/JavaScript. See the following code: class Example someFunction = -> alert @getText() constructor: -> @text = 'Hello world! ;)' someFunction() getText:…
Caio Tarifa
  • 5,973
  • 11
  • 46
  • 73
4
votes
4 answers

C# : Difference between method types

Possible Duplicate: What is the difference between Public, Private, Protected, and Nothing? I have a question : What is the difference between these method types ? Static , Public , Internal , Protected , const , void Sorry my question may seem…
R.Vector
  • 1,669
  • 9
  • 33
  • 41
3
votes
3 answers

too many public methods with @ModelAttribute

I have a controller that is 1600 lines long. This is mostly populated with a bunch of public methods with the @ModelAttribute annotation. It also has a few @RequestMapping methods. I would like to bring down the line count and break-up this…
pslk
  • 31
  • 3
3
votes
4 answers

Is there a way in Ruby to print out the public methods of an Object

... without including all of the public methods of the generic Object? I mean, other than doing array subtraction. I just want to quickly review what's available to me from an object sometimes without going to the docs.
RubyRedGrapefruit
  • 12,066
  • 16
  • 92
  • 193
3
votes
10 answers

How to hide a public method?

I have a method in my static state machine that is only used once when my application is first fired up. The method needs to be public, but I still want it hidden. Is there a way to use an annotation or something that will hide the method from the…
ahodder
  • 11,353
  • 14
  • 71
  • 114
3
votes
5 answers

Why does dependecy injection use public methods?

Why does dependecy injection use public methods? Correct me if I'm wrong, but it's possible to change the implementation using reflexion.
Guillaume Massé
  • 8,004
  • 8
  • 44
  • 57
3
votes
1 answer

javadoc exclude some public methods from class

I have to exclude a few of the public methods of a class from being included in javadocs. I tried Chris Nokleberg's ExcludeDoclet (sixlegs). But the doclet is giving a slight problem : If the other methods in the class return List (or any other…
Astha
  • 31
  • 1
  • 2
3
votes
3 answers

Is it ever necessary to define a method as "public"?

If all methods are public unless they are explicitly defined as something else, is it ever necessary to define a method as public?
Emanuil Rusev
  • 34,563
  • 55
  • 137
  • 201
3
votes
2 answers

Public static methods - a bad sign?

I've just read this article here: http://hamletdarcy.blogspot.com/2008/04/10-best-idea-inspections-youre-not.html, and the last bit in particular got me thinking about my code, specifically the advice: What in the world is a public method doing on…
pauljwilliams
  • 19,079
  • 3
  • 51
  • 79
3
votes
5 answers

Public methods bxslider on multiple slideshows

I have multiple slideshows and im using this code: var demo = $('.demo').bxSlider({ mode: 'horizontal', captions: false, touchEnabled: true, controls: false, pager:false }); $('.slider-next').click(function(){ demo.goToNextSlide(); return…
krathos
  • 345
  • 2
  • 4
  • 9
3
votes
2 answers

jQuery plugin public method/function

I am trying to achieve something like the following but dont know whats wrong: $.a = function() { // some logic here function abc(id) { alert('test'+id); } } $.a.abc('1'); I tried using the return function, but that doesnt seem to work…
Alec Smart
  • 94,115
  • 39
  • 120
  • 184
3
votes
2 answers

Calling a public method in Windows Forms

I have 1 MDI Form which contains 1 panel control, and 1 Form with 1 button which serves to make panel in MDI not visible. Code in MDI Form: public void displayInit() { panel1.Visible = false; } Code in Form1: private…
Sami-L
  • 5,553
  • 18
  • 59
  • 87
3
votes
3 answers

Java2C# translation: public methods in Interfaces in C#

Another translation question, this may be more theoretical, but I am curious as to the design choice. SFNQ: Why does C# not allow controlling for controlling access to methods in interfaces like Java does? For example, in a C# interface: public…
Dervin Thunk
  • 19,515
  • 28
  • 127
  • 217
2
votes
7 answers

public or nothing

In java, do we really have to do that in order our variable or method to be public? For example: void aaa() { ... } or public void aaa() { ... } If it is a must, why?
El3ctr0n1c4
  • 400
  • 2
  • 7
  • 18