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
0
votes
0 answers

Accesssing a private struct defined in class by a friend or a member function

I want to make a public: or friend function to a class return the address of a pointer whose type is defined as a private member of the class. Example:- class LinkedList{ struct Node{ int data; Node* next; }; Node* head = NULL; Node* tail…
0
votes
3 answers

Call function from class for many classes without resetting values

so basically I have several different Java classes in Android studio. One of these classes contains a host of functions that I need to call from different classes based on what the user selects. My issue is that I need the class that I'm calling…
0
votes
1 answer

javascript singleton public method "not a function"

I give up. I'm usually a c# developer, but I need javascript for this particular project. I have a list that I want to be protected with some setters and getters (and also public methods vs private helper methods). To do this, I've implemented a…
0
votes
1 answer

in magento 2 which block methods are available in a template?

m2 is much different than m1. When I'm writing code (programming public methods) in the template they don't seem to be working. Are all methods allowed like protected and private as well? or getters or only public getters? I'm confused. I believe…
getData
  • 123
  • 5
0
votes
1 answer

My main method can't see all public methods in a different package in java

My main method in a package by itself can only see some of the methods in the other package even though they are all public. This is an example of my code. package stuff.code; public class AObject { public AObject(); …
D.B
  • 33
  • 7
0
votes
1 answer

Public/private moethod declaration-only on ES6 classes with babel

I'm using Babel with default es2015 preset to convert ES6 JS code. Since I'm working in another project with TypeScript, I've come to appreciate the publi/private annotation on methods. I'd like to use the same annotation in JS code. Even if it…
don
  • 4,113
  • 13
  • 45
  • 70
0
votes
1 answer

Trying to figure out Class and method declaration in Util classes java

I've been having some issues trying to solve this code that my professor sent to me for studying purposes. I usually can solve the isPrime and getPrime no problem but my issue lies with the gcd class. Would love to get some input on this. Thanks :)…
Kowalchu1
  • 11
  • 1
0
votes
1 answer

know the address of Arduino ethernet shield through public ip

Yes, like I wrote the ask title. I want to know it is possible know or see the someway the approximate geolocalization through public ip. I have an arduino with ethernet shield. Thanks, I've been searching for many days, but I wasn't found…
Maclos
  • 7
  • 1
  • 3
0
votes
1 answer

$.fn.myPlugin vs $.something.myPlugin in regard to private and public methods

So I can't seem to find astraight answer on this, only vague examples of multiple variations where similar plugin/method declarations are used. I know that by saying $.fn.myPlugin I am defining a publicly available plugin method that can be…
0
votes
2 answers

Confusing example of Private V.S. Public method in book ?

I've been reading Javascript Patterns by Stefanov recently. And I found this example confusing to me here: Another case of using a convention to mimic functionality is the private members >con- vention. Although you can implement true privacy in…
0
votes
1 answer

What are the pros on passing variables using Bundle instead of publics methods?

I'm taking the developing android app's course on udacity. I was wondering if I am right in an alternative solution for Lesson5: Handle List Item Click. the challenge when we have 2 panels and we clicked an item from the List, Uri should pass…
0
votes
1 answer

Accessing public variable from another C# Class using Unity 5

I'm using Unity 5 and mono develop for C# editing. I have one C# file that reads a CSV file and creates a string from the content within the CSV. I made this class a public class with a public string variable because I want to be able to access this…
0
votes
3 answers

Web API 2 accessing ServiceController : ApiController public variable from class

Hey all I am trying to figure out how to go about access a variable from the ServiceController : ApiController like so: namespace WebApi.App.Controllers { public class ServiceController : ApiController { string outputFile =…
StealthRT
  • 10,108
  • 40
  • 183
  • 342
0
votes
2 answers

How to call Public method from Form1.cs with Combobox item

In my code in POI class I want to implement some method, at first it will take data from .xls file.Then it will show city and population name in the datagridview table.Now from datagridview table it will take only the city name which will show in…
Nowshin
  • 67
  • 1
  • 2
  • 11
0
votes
2 answers

correct way of using public methods

whats the correct way to use public functions/variables? I mean should i create a new class filled with everything that is public? like a PublicFunctionsAndVariables class? namespace TestProgram { class PublicMethodsAndVariables …