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
-
0
votes1
answer42
viewsAngularjs - Changing view with json return
My app checks the state of a bulb and creates an animation in the view. I am making a request ajax with angular and in return for success I have to animate a lamp lighting, follows excerpt from the…
-
0
votes0
answers123
viewsHow to generate multiple nested repeat structures with methods
need to generate several nested structures (26) wanted to know how to do this with methods pro code not get too big an example of the structure I need with 4 nested: public static void main(String[]…
-
0
votes1
answer36
viewsCalling a method
Hello, I would like to do something extremely simple, but I’m having difficulty applying. I made the following class: public class nome { string aluno = "Olá, eu sou um aluno"; string aluna = "Olá,…
-
0
votes0
answers21
viewsHow do you take the value of a static attribute inside a method when you have a variable with the same name in that method?
When it is a non-static attribute you can use the this.nomeAtributo. Example: public class NomeDaClasse { private String atributo; public void (String atributo) { fazerAlgo(this.atributo);…
-
0
votes0
answers49
viewsHow to optimize a power loop of 2 n and (2 n)+1 in java?
Good, I’m doing a job where I have to do tests in Stacks, and the tests have to be done when I push and pop of powers of 2 and powers of 2 plus one (1,2,3,4,5,8,9,16,17, etc...) I got some code…
-
0
votes1
answer446
viewsInstantiate class in method parameter or within method
Working with an Laravel controller I came across something similar to this: public function show(Role $role) { // é apenas um exemplo. } Where the Role class is instantiated in the variable $role…
-
0
votes1
answer38
viewsreceive an object in a method of the same type as the method class
I’m passing a java code to python and came across it(cutting a few parts) public class TreeNode { public TreeNode(TreeNode pai) { how do I receive the father of the type Treenode in python? class…
-
0
votes0
answers238
viewsCalling a method in another Android class
Good morning gentlemen, I’m with a doubt, I’m trying to call a method that is in another class but is not working, this same method already works if using another layout, just wanted to implement it…
-
0
votes1
answer34
viewsHow do I value a value passed by Set?
I wanted to know how do I add a new value to length and width through setLength and Setwidth, and this value goes through validation ((x > 0 && x < 20)? x : 0): public class Rectangle…
-
0
votes1
answer1135
viewsC#, what are methods, classes, and objects?
What are the differences between the three? Do they have any other differences? I’m new to development, and I want to learn more.
-
0
votes1
answer48
viewsHandling object only in methods
When I create an instance of a class I can access its attributes only when I’m inside a method, why? In the example below I can give a set in the method main() but not within the class, why? public…
-
0
votes1
answer66
viewsError using Mainactivity method in Fragment
I am trying to use a method that returns a list, when using this same method inside the mainactivity where it was created everything works well, but when trying to access it in a fragment of the…
-
0
votes2
answers81
viewsPython: Return a list in 2D format
I want to use the __str__ to receive a list and returns it in the form of a matrix. Example: list_exemplo = [[0,1], [2,3]]would return as: [[0, 1], [2, 3]] How do I do it in the method __str__?…
-
0
votes1
answer250
viewsCalling element of one method in another method
When I run the program, in the method "exibirVetores(int[] vet, int[] vetInvertida)", as Strings "inverted" and "normal" are empty (null). public class metodos02 { public static Scanner sc = new…
-
0
votes0
answers55
views -
0
votes1
answer159
viewsVirtual method with Generic C#
I am creating a Base Form where I am not using it of type "Generic" due to problem with inheritance of forms in C# with the same. In this base form, I had the need to create a virtual method with…
-
0
votes1
answer110
viewsWhy is one method that uses polymorphism being called in place of another in case of inheritance?
Could someone explain why the output of the program is: Primate walking Mammal listening Man seeing. Shouldn’t be?: Primate walking Mammal listening Mammal selling Year: 2019 Banking: IDECAN Organ:…
-
0
votes2
answers238
viewsMore than one return on a method in PHP
For example I have the following function: <?php public function login($username, $password) { if($condicao === 1) { return true, } elseif($condicao === 2) { return 'qualquer string'; } else {…
-
0
votes0
answers360
viewsCall a method of a class from a function within the class itself? C++
I created the "checkCase4" function in my Tree class and within it I make 2 class methods (rotate_left and rotate_right). Function: void checkCase4(Node *child, Node *grand) { if (child ==…
-
0
votes1
answer1059
viewsCreate separate method to call Activity
i created a script where I intend to call separate activities but it’s not working package com.example.john.new_login; import android.content.Context; import android.content.Intent; import…
-
0
votes1
answer281
viewsError using System.Windows.Forms.SendKeys.Send("%{DOWN}")
In a windows form application I have a Datetimepicker and I do not want it to display the date so I did the following: public CadNovoPagamento() { InitializeComponent(); dtpEmissao.Value =…
-
0
votes1
answer49
viewsDoubt about methods
I am learning by the book Use the Head and in it there is the following code to do an exercise of random items public class Menu { public Random Randomico; string[] Carnes = { "Rosbife", "Salame",…
-
0
votes1
answer100
viewsDoubt about Python methods and classes
I have the Login class and created an instance of it in the Main class, with the instance I am calling the start method, but in the start method when clicking the 'Log in' button the…
-
0
votes1
answer107
viewsWhy does the class accept parameter and the method does not?
I’m studying classes in Python and I don’t understand one thing: considering the last two command lines below, why the value 4 is accepted in the class Operators and not in the method metade()? Do…
-
0
votes0
answers43
viewsI have a simple class and it doesn’t answer when I call the methods
Can someone help me? class sorvete(): def __init__(self,sabor, recipiente): self.sabor= sabor self.recipiente= recipiente self.ml= 0 def sabor(self): print("O sabor que pediu é: ", (self.sabor)) def…
-
0
votes1
answer91
viewsPrivate method in JAVASCRIPT class
How to define a private method in a class JavaScript in order to make the method msg_privada as private (not externally visible) without changing the rating pattern? The method msg_privada must be…
-
0
votes1
answer54
viewsProblems with Node + express routers
I have a sequence of methods (get, post, put, delete), however the put method is wrong and I do not know how to solve. this is the code snippet: router.route('/') .get((req, res) =>…
-
0
votes1
answer942
viewsRelation Between Classes in Python
Imagine that you are developing a system for controlling a Vehicles. With this it is necessary to register the vehicles available at the dealership for sale. a) Think about the necessary data and…
-
0
votes2
answers171
viewsHow to reference methods that use array as an object in the console?
I have a class with the following attributes and constructor: private Person[] persons; private int personCount; public PersonDatabase(int defaultPersonsCapacity){ persons = new…
-
0
votes2
answers69
viewsAndroid Studio does not recognize the getRating() method
When I try to use the getRating() method in the Formulariohelper class Android Studio informs that "Cannot resolve method 'getRating()'". I’m importing the package from View and Ratingbar and yet…
-
0
votes2
answers104
viewsI want to understand how the instance variable and the local variable of the parameters works
public Exemplo { private int name; public Exemplo(int name) { this.name = name; } public void setName(int name) { this.name = name; } public int getName() { return name; } } I want to understand how…
-
0
votes1
answer64
viewsHow to delegate UI methods automatically
I created these methods in the interface: public interface IEvents { void OnEscrever(string text); void OnEnable(bool b); void OnDisable(bool b); } I’ll have some classes that will inherit these…
-
0
votes5
answers153
viewsCall the Java method
I’m doing some POO exercises and I can’t call the method ligar of my code. public class Telefone { public String modelo; public int numeros; public boolean antena; void status(){…
-
0
votes0
answers91
viewsError calling android studio java method
I’m having the error of: java.lang.NullPointerException: Attempt to invoke virtual method 'android.content.res.Resources android.content.Context.getResources()' on a null object reference when…
-
0
votes1
answer1183
viewsWhen to use "map()" or "toList()" methods?
In the example below, the two methods basically do the same job, go through the list of objects getting each item from the list. A difference is noted in the iteration using map(), in the last…
-
0
votes1
answer38
viewsHow to display the line number of a method in Java?
Good morning , I am using AST , so I was able to access the methods, attributes and get if it is public or private, among other things. How do I display the line number of a particular attribute or…
-
0
votes3
answers99
viewsReturn method asks return that has already been given
I have the following class: public class Exemplar { private boolean disponivel; private int codigo; // seus setters e getters } and this other: public class Biblioteca { private…
-
0
votes1
answer92
viewsHow exactly does "private" and "protected" work in Ruby?
I’m studying Ruby and arrived at the access control part. I had studied before access control in Java, then I thought it would be the same, but to my surprise, the statement private and protected…
-
0
votes1
answer183
viewsInsert using methods and classes in the C#database
Hello, good afternoon, sir! My problem is the following: I am wanting to run an Insert event, which in the database will add the (name, user, sector, position, shift and extension), but now I am…
-
0
votes1
answer58
viewsProblem making a method call in class constructor (javascript)
I am learning javascript and am getting the following error: setTitulo is not defined Why does this error happen? The setTitulo method should not be set since it belongs to the class? class Nota{…
-
0
votes1
answer59
viewsDoubt about the replace() method
The replace() method is a method of the str class, correct? Follows a code that 'rotates' perfectly where the object is an integer (or at least in my interpretation). Or in the case of interpolation…
-
0
votes2
answers37
viewsHow to pass method objects that are in different controllers in Laravel?
Good night. What I need is to display the name of the book where your id is (in the Form Book column). And so that I don’t do it in a way outside the convention, I’d like to know the right way to do…
-
0
votes1
answer268
viewsInserting in a python sqlite3 database by a class
I am doing a mini project of a registration in a database sqlite3 by python, my problem is that in my method, which registers the product with (id, name, purchase price, sale price, quantity), gives…
-
0
votes1
answer50
viewsDoubt with exercise of Ecmascript 6
This Ecmascript exercise talks about the creation of two classes, one of user (where the email and password will be entered), the other of administrator (where in addition to the email and password…
-
0
votes0
answers23
viewsUse the matrix of one method in another method to change its values
I’m doing a job that involves manipulating images in java ( I use Intellij) for my degree. I present below my code and what I would like to do is apply the operations of method alineaC in the matrix…
-
0
votes1
answer26
viewsVoid method returns items to the list, but when I try to use this list, it is empty!
listaPedidoComprador.setLayoutManager(new LinearLayoutManager(this)); listaPedidoComprador.setHasFixedSize(true); adapterPedidoComprador = new AdapterPedidoComprador(itensCarrinho2);…
-
0
votes3
answers95
viewsPass Enum value per method parameter
I have a value that stores the status of an element. For example: 1 - sending 2 - Cancelled 3 - Error. The value that will be saved in the database is the numeric value. I have a method that sets…
-
0
votes2
answers44
viewsRun method in Form1 for form2 change
I’m developing an inventory manager, and the data is being stored in a database. The problem I’m facing is this: when I add a new product for example, I created a "Update list" button (I left it in…
-
-1
votes2
answers38
viewsHow to make constant member functions in Php?
I was studying what my book called "constant member functions" in C++. i.e., functions that cannot change any class attribute or call other methods that are not constant. So, I made this code in…
-
-1
votes1
answer316
viewsHow do I call a method that is in another class on onclick
Guys I have a simple doubt basically, but I’m traveling on ideas. I have a class called chamada: @Override public boolean onLongPressClickListener(View view, int position) { // opcional, utilize o…