Most voted "method" questions
A class method is nothing more than a collection of instructions grouped together for the purpose of executing a given task.
Learn more…271 questions
Sort by count of
-
6
votes1
answer666
viewsPassing optional arguments in Java
I’m trying to learn how to run the class SwingWorker<T,V>, I’ve even done another question regarding one of its methods. Looking at the source code of this class, I found the method publish()…
-
6
votes1
answer155
viewsC++ overhead in method header
I’ve been analyzing the performance of a Directx renderer through the VS2015 Performance Profiler tool and it pointed me to an overhead in the header of a very requested renderer method, as shown…
-
6
votes1
answer125
viewsDifferences between defining object methods using Arrow Function and Function Expression
About "flammable" methods outside objects, I can say that these three forms below act in the same way within my code? Examples: var barquinho = { pedro: () => { console.log("a"); }, tiago:…
-
6
votes1
answer499
viewsR - download CVM data via POST (package httr) method (new - continue)
Good afternoon guys!! I would like to have asked this question there in this post, which I reference in the title, however it was not possible. What happens is this: I am using, for the same…
-
5
votes4
answers661
viewsHow do I execute a method at the end of each method in my class C#
He had a father class and another daughter and would like to perform a certain method, as an event, always at the end of each call of the method of the daughter classes. How can I do?
-
5
votes2
answers2743
viewsHow do I set a private property in Python? And is there a protected property?
I come from PHP. In it, when we want to define a property of a class as private we add the keyword private in his statement. Example: class StackOverflow extends StackExchange { private $language =…
-
5
votes2
answers2039
viewsWhat is a hook method?
I am studying some design standards and came across this method, however, its concept was not clear to me. What the method does and how it relates to the Template Method? I’d like an example in…
-
5
votes1
answer75
viewsIs it possible to hide a public method from the abstract class?
I have the following scenario: public abstract class ClasseA { public string[] MetodoC(string parametro, string nomeObjeto) { // ações metodo } } public class ClasseB : ClasseA { public string[]…
-
5
votes2
answers887
viewsCalling a string equivalent method
Consider the following class: public class AnimationManager : MonoBehaviour { public GameObject[] Enemies; void OnTriggerEnter2D (Collider2D o) { if (o.tag == "Player") foreach(GameObject Enemy in…
-
5
votes3
answers3518
viewsHow to solve the problem "The main method was not found" in a Java class?
I created this Arraylist and at the moment of execution the following message appears: Error: Main method not found in class Declaracaoarray.Declaracao_array; set the main method to: public Static…
-
5
votes1
answer112
viewsHow and when to use "Shadows" and "Overrides"?
How and when to use Shadows and Overrides? What are the usage recommendations for each and in what context to use them?…
-
5
votes1
answer2013
viewsHow to use runOnUiThread()
I’m studying the use of Threads, aSynkTasks and Handlers and came across this method, runOnUiThread() How does this method become a repetitive process to the point of replacing Handler? How this…
-
5
votes3
answers219
views -
5
votes1
answer159
viewsPurpose of lambda syntax in function/method
In some cases a function/method contains only one line in its scope, see the illustrative example: static int Soma(int a, int b) { return a + b; } Meanwhile, to a new feature in C# 6.0 that allows…
c# function lambda-expressions characteristic-language methodasked 8 years, 4 months ago gato 22,329 -
4
votes1
answer367
views"cannot be resolved to a variable percentage"
I need to set the variable value porcentagem as defined in Spinner. The problem is that I need to use the value of porcentagem out of method setOnItemSelectedListener(), on the line int r =…
-
4
votes2
answers887
viewsCan I use a variable to overwrite a method?
When rewriting a method, in PHP, I can use a variable to receive the method? I did the example below and it worked normally, but I don’t know if this is correct or if it is the best way to rewrite a…
-
4
votes1
answer99
viewsDoubts with Arrays in C#
Good night, you guys. I am a beginner in programming and have two questions: When a double array is maintained in C#, each position of the array starts-without as null or zero? Is there a method…
-
4
votes1
answer92
viewsHow does one method work within another? E.g: service.metodo(arguments). execute();
I’m not understanding this method within another method someone explains it to me? Another example of my doubt: ImageKeywords keywords = service.getImageKeywords(image, forceShowAll,…
-
4
votes2
answers164
viewsTypes of C#Methods calls
I have a question in the following case, not referring to dates, I used only as an example: Convert.ToDateTime("01/01/2016 00:00:00").ToShortDateString(); What is the origin of this method…
-
4
votes1
answer3440
viewsHow to override equals method?
I am trying to overwrite the equals method for instead of validating if an entire object is equal to the other just check if a value this object is the same as the other. Cenário Real: Student…
-
4
votes1
answer191
viewsisUserAMonkey() and isUserAGoat() methods
What is the real function of the methods isUserAMonkey() and isUserAGoat() in the Android SDK? In what situation they should be used?…
-
4
votes3
answers667
viewsDoes the PHP method have line limits?
The size of the method is 22 lines. (20 Allowed) Netbeans gives me this "warning," so why? It’s a PHP rule? What’s best: A great method with all the code he needs. Split this code into smaller…
-
4
votes1
answer325
viewsMethods with Dynamic C#parameter
I need your help with the following question. I have a data access class that has a method that takes the parameters to run a stored database. The problem is this, I have several objects in the…
-
4
votes1
answer824
viewsHow to return 2 objects at the same time in a Java method?
public class Equacao2Grau { int a, b, c; public int CalculoDelta(){ return (int) (Math.pow(b, 2) - 4*a*c); } public int FormulaQuadratica(){ int x1…
-
4
votes2
answers455
viewsHow to fix this error "Cannot Convert from 'int' to 'char[]'
Why is this error presented? I believe the logic is right.…
-
4
votes2
answers992
viewsIs it possible to pass a method as a parameter to run on a thread?
I have an application where each process is called by a single method and this process needs to run in a thread. The code of the threads is identical in all, changing only the content of the method…
-
4
votes3
answers180
viewsHow to use repeated methods?
I have some methods that I use in various points of the applications and I end up having to copy in each class. For example: String getStringOrEmpty(EditText editText) { String mString =…
-
4
votes3
answers388
viewsIs it possible to offer return options in a method?
As far as I know Overload in the creation of methods, which are execution options, example(very simple), a method where you have the option to pass 2 or 3 parameters calling the same function:…
-
4
votes1
answer73
viewsAre methods objects in Ruby?
Ruby’s got the class Proc, that is defined in the documentation as Blocks of code that have been bound to a set of local variables. Once bound, the code may be called in Different contexts and still…
-
4
votes1
answer79
viewsIs it possible to force a method to be extended in Java?
It is possible to "force" a method to be extensible? The statement of the exercise says exactly this: we have to create a class, within it create a method and force this method to be extended. From…
-
4
votes1
answer83
viewsHow does the compiler know that class x is an extension?
In this example, I create a class extension method DateTime in the c#: static class DateTimeExtensions { public DateTime PrimeiroDiaDoMes(this DateTime data) { return new DateTime(data.Year,…
-
4
votes1
answer95
viewsHow to popular a parameter property with GET access
To understand what I want to do, note the Formclosing() parameter of Windowsforms: private void Form1_FormClosing(object sender, FormClosingEventArgs e) { var r = e.CloseReason; } By analyzing this…
-
4
votes2
answers88
viewsA Setter method can receive a getter + value as a parameter?
I created the advisory methods Setter and getter for the balance attribute. It is correct to use these advisors within each other? One being used as parameter for the other. More specifically the…
-
3
votes2
answers432
viewsCreate a set method for different variables
I’m looking to create a Setter for an object Character, where it will modify the attributes String name, int intellect, int strength and int stamina, but what is the best method to do this? public…
-
3
votes4
answers3475
viewsHow to return 2 variables of a function
I am accessing a webservice, that has as return: listProdutos[] -> List of all products or null when there are no products When you lose access for some reason, you make an exception, in which…
-
3
votes1
answer218
viewsDifference between Contents() and html() methods
I needed to get the contents of a iframe (which was in the same domain on the same page) with html(), but to no avail. Then I saw that there was a method called contents(), and worked out using it.…
-
3
votes2
answers92
viewsHow to take the signature of changed methods in a commit
So guys, I need to subscribe to all the methods that were changed in a commit, whether updated, removed or added. Example: In this commit The changed methods were: - br.ufrn.ase.Classe1.metodoB(int…
-
3
votes1
answer120
viewsAre methods and builders the same?
Some sources say that constructor is a special type of method, while others say constructors are not methods. Some say, too, that although they are different the JVM treats them the same way. After…
-
3
votes1
answer234
viewsHow to override the remove() method from Iterator?
I created a repository (RepositorioObjeto) and it implements the interface Iterator on the object the repository stores (Iterator<Objeto>). So I had to override the methods next(), hasNext()…
-
3
votes1
answer278
viewsHow to create a json from my object?
I have a Product object that I can’t turn into json using json_encode: <?php class Produto { public $nome; public $preco; public $descricao; function transformarJson(){ } } ?> How can I do…
-
3
votes2
answers284
viewsHow to implement classes with private method?
I am rewriting the code of an application seeking the best use of interfaces and I came across a problem: I have a class that needs to have a private method and I want to create an interface for it,…
-
3
votes2
answers321
viewsProblem with hasNext() Java
Hello, I have a problem, I scan a txt file, then I invoke a method to go counting the lines of this file, after returning me the number of lines (to give the size to the String Array equations)I…
-
3
votes1
answer9873
viewsHow to create a class with attributes and methods in C++?
In Java I know how to do it, but in C/C++ it’s little different so how to create a class with attributes and C methods++? I am using Codeblocks. When I create a class in C++ it creates two files one…
-
3
votes2
answers837
viewsOperator error cannot be applied to the method group
I’m trying to print a date subtraction using C# with Webforms, but I don’t know how to correctly insert attributes in methods or how to print the method. I’m converting the subtraction of dates into…
-
3
votes2
answers70
viewsSet values inside or outside the method?
I’m studying about passing parameters in PHP. I want, for example, to use a certain method that needs to receive two values, I have the following codes: Example 1 In the class: class Exemplo {…
-
3
votes2
answers883
viewsHow to check if a method exists in a Python class?
How to check if a method exists in a Python class? Is there any function that does this? class Test(object): def method(self): pass For example, I would like to check through a condition if a…
-
3
votes2
answers441
viewsPython dot notation ( methods )
How to create point notation methods, those that are called object.show () instead of show ( objec ), or they apply only to strings, if yes why exactly ?
-
3
votes3
answers823
viewsMethod that returns parent class to daughter class
I have the following classes: public class Pessoa { public int PessoaId { get; set; } public string Nome { get; set; } public DateTime DataNascimento { get; set; } } public class Cliente : Pessoa {…
-
3
votes2
answers843
viewsOverwrite methods based on name only
I’m creating an abstract base class to provide a pattern for other classes. The base class methods shall be superscripted in the derived class. Now comes the cat jump. The superscript should happen…
-
3
votes1
answer3125
viewsWhy does calling a simple method in a class give a reference error?
I’m starting to study C# and I’m making the following mistake: CODE: CS0120 DESCRIPTION: An Object Reference is required for the non-static field, method, or Property…