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

Public method in public inheritance becomes private in C++

I have a base class with a public method, but when I try to call it from a derived class which inherits publicly from the base class it becomes private. How is it possible? Shouldn't public inheritance means that public methods are kept…
-3
votes
2 answers

Using CurrencyInstance in a double instead of a String

Pretty simple question I imagine, just can't seem to figure out the right way to do it. I have a method that produces my total "cost" (a pre-defined 'double' variable) as a dollar amount here: import java.text.NumberFormat; public class Example {…
BCarmar
  • 11
  • 7
-3
votes
1 answer

My method cannot return a value?

I wrote a method but method cannot return i value. What can I do ? public static int contain(String s1,String s2){ //I want wrote a method similar contain if(s1.length() == s2.length() || s1.length() > s2.length()){ for(int i = 0; i <…
-4
votes
1 answer

How do i Declare methods in public and write the code in private

I have been given this code with the restraints that i can not edit the public in anyway and am not allowed to call any other library's other than the ones specified. Class example { private: vector vector_1; void function_1(string name) …
herbeir
  • 1
  • 1
1 2 3
12
13