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
1
vote
5 answers

PHP object functionName():bool

I've one PHP class, in that I found one a function e.g public static function success(string $userid, string $message):bool { return self::add($userid, $message, 'success'); } Can someone please tell that what does mean :bool after function…
techsu
  • 753
  • 2
  • 7
  • 11
1
vote
6 answers

Why is a template method marked final?

In template method pattern, there is a method marked final, but I cannot understand the meaning of having this method. Please help me out. In another word, in class PackageA, one can implement the algorithm for each abstract method as needed. And…
1
vote
2 answers

C# public partial struct methods for more System.Windows.Media.Color

How can I put in additional methods for manipulating color ? Best would be to overload the struct System.Windows.Media.Color. It is NOT a class (in c#). Now i'm tinkering with putting (in the same file for testing or must i put it in a different…
dr d b karron
  • 187
  • 2
  • 16
1
vote
1 answer

Angular2 self.parentView.context is not a function

I've got a button element in my *ngFor list item:
  • Alexandr Belov
    • 1,804
    • 9
    • 30
    • 43
  • 1
    vote
    4 answers

    Converting public method to extension method

    In my project's core library we have a very big class, which is tending to become a God object. One of the reasons is that, over a period of time, tasks which should have been in different modules have been put into this class. For ex - class…
    Unmesh Kondolikar
    • 9,256
    • 4
    • 38
    • 51
    1
    vote
    4 answers

    Use class method from another class

    I am trying to use a method inside class, from another class. namespace Crystal.Utilities { public class Logging { public static void Log() { //dostuff Crystal.MainForm.general_log_add_item("Hello World"); …
    Dominik Antal
    • 3,281
    • 4
    • 34
    • 50
    1
    vote
    2 answers

    What is difference between published and public methods / attributes?

    According to Martin Fowler "Something can be public but that does not mean you have published it." Does this mean something like this: public interface IRollsRoyceEngine { void Start(); void Stop(); String…
    Prajwal Tuladhar
    • 543
    • 1
    • 5
    • 12
    1
    vote
    2 answers

    Mono: non-standard public method in Object class

    Does anybody know what is the "obj_address" public method in .Net Object class Mono implementation? Thank you, Michael
    galenus
    • 2,087
    • 16
    • 24
    1
    vote
    1 answer

    specify a object on a public method

    I have the following method public partial class formTabelasPsi : Form { private Form1 Opener { get; set; } public formTabelasPsi(Form1 opener) { this.Opener = opener; InitializeComponent(); } public static…
    ng80092b
    • 621
    • 1
    • 9
    • 24
    1
    vote
    6 answers

    Factory Method pattern and public constructor

    Im making a factory method that returns new instances of my objects. I would like to prevent anyone using my code from using a public constructor on my objects. Is there any way of doing this? How is this typically accomplished: public abstract…
    Brian Hvarregaard
    • 4,081
    • 6
    • 41
    • 77
    1
    vote
    0 answers

    Can't access public variable in public method?

    Possible Duplicate: JS Object this.method() breaks via jQuery Hello, I'm playing around with creating classes in javascript but I don't think I really understand everything. Here is some (simplified) code I wrote (the .bind() comes from jQuery…
    Kristof Claes
    • 10,797
    • 3
    • 30
    • 42
    1
    vote
    1 answer

    Trouble Accessing My Public Sub

    I created a public class and a public sub that contains all the code needed to save my application, and I want to be able to use this sub in other classes. But when I type Call Save.Save() (the first save is the class name, the second the sub name),…
    1
    vote
    1 answer

    PHP PDO: Should we set pdo's `function __construct` to `private` or `public`?

    Should we set the pdo's function __construct to private or public? Will it be a subject of vulnerability if I set it to public? Here is my db class, class pdo_connection { public $connection; // handle of the db connexion public function…
    Run
    • 54,938
    • 169
    • 450
    • 748
    1
    vote
    2 answers

    Can other apps on Android phone access public methods

    According to a manual on basic Android programming, "the public modifier means that any Java class, even classes outside of the package, can use that method or variable." I understand this concept in general terms, but am wondering how it plays out…
    Aaron Delwiche
    • 79
    • 1
    • 10
    1
    vote
    3 answers

    Make form function accessible to all forms

    I have this function on Form1, and I want to use the same function for Form2, Form3 and so on, instead of duplicate the function on each Form is there any way to make it accessible for all? I've tried to make a new Class : Form and then call the…
    Robert W. Hunter
    • 2,895
    • 7
    • 35
    • 73