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
1 answer

Invoke a method from another class, without reinitializing it

I've a ViewController where I call a method from another class (TCP class), where I make a TCP connection to a server, that gives me a response. And I want to, when that TCP class, get's the response from the server, call another method from the…
88fsantos
  • 393
  • 1
  • 7
  • 22
1
vote
3 answers

ocjective-c Obtain return value from public method

I'm pretty new to objective-C (and C in general) and iPhone development and am coming from the java island, so there are some fundamentals that are quite tough to learn for me. I'm diving right into iOS5 and want to use storyboards. For now I am…
0
votes
3 answers

C++ Concepts Acessing public methods

#include class Test { public: int i; void print() { std::cout << "Hello" << std::endl; } }; int main() { class Test *p = NULL; p->print(); (*p).print(); } Output: Hello Hello I understand that…
Sanjay
  • 7
  • 1
0
votes
2 answers

Is there a way to save a chosen color as a public variable?

I am implementing a Color Picker into my app. It works as intended, but i need to save the color as a public variable to use it in the next View. I have coded the following: struct Upload: View { @State var selectedColor = Color.black …
KodeKat
  • 15
  • 4
0
votes
3 answers

Accessing public methods of Activity

I am new to android development and have a confusion that if an activity( a class extends Activity) has some public methods, can we access these public methods outside that activity. Regards, Waneya Iqbal
Waneya Iqbal
  • 1,559
  • 4
  • 13
  • 17
0
votes
2 answers

Cannot be referenced from a static context

I have the following problem, I am trying to call InterstitialLaunch.java from MainActivity.java to display Interstitial, however, in my case it reports an error from MainActivity.java and says that 'inter_launched (android.content.Context)' cannot…
Dejo
  • 141
  • 1
  • 8
0
votes
2 answers

Make a String in java Global

I am an Android developer and I have made a string for generating a random 6-digit OTP which is there in the protected void onCreate(Bundle savedInstanceState) {, the first thing in a java program.: String otp = new…
user14355661
0
votes
1 answer

PHP is it okay to use (new self) often to access public methods within the static method

By following the OOP approach, I am writing reusable methods into traits rather than creating a plain helper file. So that I can control access in an organized way. For that, I have created various traits for instance, permissions, auth, settings,…
Code Lover
  • 8,099
  • 20
  • 84
  • 154
0
votes
0 answers

calling a public method of the same class twice in another public method

i have two methods in same class method1() and method2(). method 1() is to read a 'String' and extract integers from that string and method2 () is to perform a click operation. This click operation changes the 'string' which is the input of method1…
0
votes
1 answer

What is the difference between inherited methods and public methods?

I have trouble understanding how an inherited method in a subclass from a superclass differs from a public method in a class which can be used in another class.
user12599146
0
votes
2 answers

Calling a public method

I'm trying to figure out how to centralize a method that I use in a few of my ViewControllers. I already had a singleton that I was using for some variables. I called the singleton class Shared. I moved my method to the Shared class and tried…
Jody G
  • 583
  • 8
  • 21
0
votes
0 answers

How can i access class methods and attributes inside a function in class

I have a class which contains a function, so I want to be able to call a class method inside the function I want to find a way to access the class method send and the attribute file inside the worker_fn function ? class Upload { *…
0
votes
3 answers

ClaiR/Rascal: Best way to list public functions?

I am parsing an C++ header file using ClaiR and want to get a list of the public functions. visit(ast) { case \class(_, name(n), _, decs): { println("class name: "); isPublic = true; for (dec <- decs) { …
Matty
  • 134
  • 1
  • 7
0
votes
1 answer

Issue calling public function in main

I'm trying to call the public function validInfixCheck() in main but I'm getting this error when trying to compile: g++ calculatorMain.cpp CalculatorExp.cpp In function `main': calculatorMain.cpp:(.text+0x99): undefined reference to…
crownM
  • 31
  • 5
0
votes
1 answer

Java Class variables are not immutable despite restricting access

I have a matrix object that I have written. I have intended that the matrix is immutable as an attribute of the object, implemented with a mutlidimensional array. as this.matrix. When I call the matrix methods. it is made sure to return a new matrix…
bell_pepper
  • 187
  • 11