Questions tagged [methods]
A method is a block of code that performs a task and is associated with a class or an object. It is related to the non-object-oriented concepts of functions and procedures.
29,406
questions
0
votes
0
answers
16
views
Element.children.item() method
I was searching for the easiest way to access an element child, I found a method called Item() that takes the index and returns the child node, but I tried to pass a class name into it, and it worked ...
0
votes
1
answer
24
views
Can I make an asynchoronous method in python?
I have started learning about async in python. But in examples, I only see people use async keyword in functions. I wonder if I can use it with methods?
Here is what I tried:
import asyncio
class ...
0
votes
2
answers
34
views
Random div generator with javascript
<div class="btn-div">
<button class="btn btn-primary">Add div</button>
</div>
<div class="wrapper">
</div>
I've written a ...
0
votes
2
answers
38
views
Using Arrays.toString on a method output, but it doesn't seem to convert [duplicate]
I want to print out the result of a matrix multiplication method so it's "human friendly" and I can check the results. I'm using the Arrays.toString method which I have successfully used ...
0
votes
0
answers
11
views
Gradle sync failed.Basic functionality will not work properly
How to solve this error org.gradle.internal.metaobject.AbstractDynamicObject$CustomMessageMissingMethodException: Could not find method compile() for arguments [me.leolin:ShortcutBadger:1.1.22@aar] on ...
0
votes
2
answers
31
views
How to write this function with forEach?
I am trying to group the people by their age and as you can see, my code works with the reduce method. I managed to get this working but now I want to do the same with forEach method. Here's my code:
...
-1
votes
1
answer
18
views
Use a function to pass a file into a class method, and use the file in the method to access private object attributes. Trying to "load" a saved object
I'm trying to make a save/load function in my program. I have the saving part down, it works well. I'm trying to do a reverse of the save and load the object instead. I passed the file into the object ...
-1
votes
1
answer
24
views
Java ArrayList Exception - java.util.ConcurrentModificationException [duplicate]
I am trying to find longest word in a sentence. That's why I use ArrayList. But I get an exception:
Exception in thread "main" java.util.ConcurrentModificationException
at java.base/java....
0
votes
2
answers
34
views
ActiveRecord:Base
Can someone please explain to me what the difference between ActiveRecord::Base.connection(some table) vs ActiveRecord::Base.connecton.execute(some table) is? Thank You!
0
votes
2
answers
29
views
Use numerical methods to find the value of 6 variables using 5 equations
There is one combination of b1, b2, b3, r1, r2, r3 which meets the following equations:
b1 = 4 * r1
b2 = 4 * r2
b3 = 4 * r3
b1 = b2 + b3
r1 = r2 + r3
I have been trying to write a piece of python ...
1
vote
1
answer
24
views
Pulling out certain strings from split method
I would like my output to be only words in parentheses inside the string without using regex.
Code:
def parentheses(s):
return s.split()
print(parentheses("Inside a (space?)"))
print(...
-7
votes
0
answers
40
views
Can use method inculde varibale as array in Java? [closed]
I have been doing simple exercise for Contact manager
class Contact{
String name;
String email;
String phoneNumber;
}
and then he creates another class called ContactsManager, and uses ...
0
votes
1
answer
17
views
Regarding nested objects, what is the best practice for assigning a value to a key using a method that is in the parent object? [duplicate]
What is the best practice for assigning a value to a key using a method that is in the parent object?
I have tried several variations of the following:
const data = {
one : {
a : {
hours : ...
-1
votes
2
answers
27
views
Method split(String) is undefined for the type ConcurrentHashMap in Java
I am trying to write a method, AddWordsInCorpus, which would use the strings for each entry in the ConcurrentHashMap called lemmas( get the strings stored in the values), split them by space into ...
0
votes
1
answer
38
views
How to generalize methods using functional Java
Can we reduce code duplication with these methods with the new java functional paradigm? I tried to pass the function as param. But one has Functional and the other BiFunctional. Unable to make it as ...
1
vote
1
answer
19
views
Data not transferring between classes
I have three linked lists called "Titles" (String linked list), "Descriptions" (String linked list), and "Pictures" (Bitmap linked list). I'm 100% sure that they are full ...
-2
votes
0
answers
81
views
Should I always pass by reference in C++ [duplicate]
im new to c++ and i want to know if it is more efficient if im passing by value or by reference. Here i got for instance a program which takes in a item and does stuff with it ( the item wont get ...
-2
votes
0
answers
24
views
static keyword (static method) not working [closed]
class Student{
int rno;
String name;
static String college_name = "TIT";
public Student(int rno, String name) {
this.rno = rno;
this.name = name;
}
void display(){
System.out....
0
votes
0
answers
7
views
Method Overloading Error- "Editors doesn't contain main type"
package MethodOverloadding;
public class MethodOverloadding {
public static void main(String[] args) {
System.out.println("Area of rectangle: "+area(14.25d, 10.65d));
System.out....
-1
votes
0
answers
5
views
my method is not working as intended #javascript [duplicate]
I am learning methods but it is not working as intended.
Code:
var car = {};
car.mileage = 98765;
car.color = "red";
console.log(car);
car.turnTheKey = function() {
console.log("...
2
votes
1
answer
69
views
What happens when a method is used on an object created from a built in class?
I understand that classes are like mold from which you can create objects, and a class defines a number of methods and variables (class,instances,local...) inside of it.
Let's say we have a class like ...
-1
votes
1
answer
30
views
printing an output from an object method [duplicate]
I want the output to be the x variable. what's wrong in my code.
class Point:
def __init__(self,x,y):
self.x=x
self.y=y
def getX(self):
return self.x
# create a ...
0
votes
1
answer
70
views
What is the best way to order methods based on a RunBefore attribute in C#
As the title suggests, I'm looking for a way to arrange methods by their attribute values in such a way that they can always be processed before the method specified in an array.
class Program
{
...
0
votes
0
answers
53
views
Request method 'GET' not supported There was an unexpected error (type=Method Not Allowed, status=405)
My scenario is as follows:
There are several entities, and I need to send custom designed email for each entity "by Id". For example, I am trying to send the email by this URL for "babs&...
0
votes
1
answer
20
views
Is it possible to create a method in a class that references another class in javascript?
Apologies if this is a newbie question but I'm learning how to use classes in JavaScript and am running into something I'm not sure is possible. Maybe my syntax is incorrect or there's a better way ...
-1
votes
6
answers
56
views
difference of two adjacent numbers in an array
I'm trying two write a method that each element in the new array corresponds to the difference of two adjacent numbers in the argument list. And the method should return a new array. I have written ...
-1
votes
1
answer
50
views
Is there a way to ovveride a method without extending the parent class?
I have a player class which extends a JLabel
public class Player extends JLabel
{
public Player(int x,int y,int width,int height) throws IOException
{
this.setBounds(x, y, width, ...
1
vote
1
answer
24
views
R different arguments for the same S4 method applied to different classes
I have just started working with S4 objects and I would like to achieve something that with S3 seems really straightforward, but I cannot figure out how to do it with S4 classes.
With S3, by using ...
0
votes
1
answer
45
views
Is it possible to pass a method of another class to a function?
I have a 2D cell array(Cell[,] _map) and methods:
private void OpenNearCells(Vector2Int cellCoordinates)
{
for (int i = cellCoordinates.Y - 1; i <= cellCoordinates.Y + 1; i++)
{
for ...
-1
votes
0
answers
25
views
When dealing with classes do methods use constructor variable or getter variable
I'm curious about classes in js, when you use the method in the following code takeVacationDays(daysOff), does this._remainingVacationDays reference the value in the constructor or the return in ...
-4
votes
0
answers
23
views
where is the error here please i need self request [closed]
`<?php
function cartdet($product_name,$product_price,$product_image,$product_detail,$product_id){
$elemnt="
<form action= echo $_SERVER['PHP_SELF']; method="post">
<div ...
0
votes
0
answers
12
views
How to limit the http method for busybox httpd
I hava a question for busybox httpd. How do I limit the http method for busybox httpd? I cannot find anywhere how to do.
-1
votes
0
answers
16
views
How can i call a method that is defined in another file [closed]
So my Eslint is giving me error in javeaScript because i am using 3 classes in a single file, i want to separate all the classes in a different file However, I also want to use the constructor and ...
0
votes
3
answers
35
views
How to know whether to use dot notation or simply insert something as an argument [closed]
For example, we have two functions, len() and title(). Why do some functions/methods, in this case len(), requires us to use an argument in order for it to do its job, while some other functions/...
0
votes
1
answer
49
views
C - How to initialize new array inside functions parameter when calling it
void someVoid(int val[]){
//doing something with val...
}
int main(){
someVoid(???);
}
I am not sure how to call function, without declaring variable first, outside function parameters, in c
...
-2
votes
1
answer
32
views
I want to create methods to search, edit, and erase arrays in a list. Does anyone have any tips or examples?
I have an assignment where I need to create a blog where people can create, search and display all posts (arrays). But for a higher grade i need to create methods for searching for, editing, and ...
-3
votes
0
answers
27
views
How to cut a text for do a line break in java? [closed]
I want to make a method that cuts a string when it has a certain number of characters without cutting entire words, to make the line break and so on until the text is finished to save it in a variable....
0
votes
0
answers
20
views
Cast identical methods from different modules in Java
My java program works with a method of an external class that I cannot modify. This method takes an object of the class com.name.xx.yyy.ResultType. The module com.name.xx.yyy is also included ...
0
votes
0
answers
26
views
how to display the instance variables in this gui?
I can't figure out how to display the instance variables in the Gui (using p5.gui) that I am trying to create for this audio Visualiser constructor function.
I have tried multiple things like making a ...
-3
votes
0
answers
20
views
Methods and bool comparison in python [closed]
Please is it possible to compare a string method and a Boolean to make an if statements ..mine returns errors
String = “2”
If String.isdecimal() == True:
Print(“it works”)
-3
votes
2
answers
51
views
How can i reverse text in python? [duplicate]
I want to reverse a text which is in variable in python but I'm not sure if we have string method for this problem or not
How can i reverse the text with strings method?
0
votes
0
answers
34
views
Getting error from Flutter "No Signature Of Method"
It says line 29, here is line 29.
android {
compileSdkVersion flutter.compileSdkVersion
ndkVersion flutter.ndkVersion
Error:
No signature of method: build_elagrqeqa0ondqjprsne9cg0n.android() ...
0
votes
0
answers
28
views
Open dialog, split and multidimensional array?
I'm new to coding and I have a pseudo specific question (it's for a class using visual studio 2017). I need to read a user selected file into an array. (OpenDialog I know) The array needs to be ...
-2
votes
0
answers
16
views
Is there a way to pass a method as parameter to a function in Javascript? [duplicate]
Im trying to do this bellow
function realizarAcao(acao){
bola.bolaAndando = true
let intervalo = setInterval(() =>{
if(bola.bolaAndando == false){
...
3
votes
1
answer
53
views
Where are the root method bodies in c#?
Where are the root method bodies in c#? How can I see it? I'm interested in how it works from the inside, but when I choose any class or method(f12) -
I see only a declaration, where is the body?
0
votes
0
answers
15
views
Odoo [0] [1] [2] after a method() [duplicate]
Odoo using methods such as .read()[0] or .append()[0] or .split(':') with [0],[1] o [2]. What are those meanings of [0] or [1] or [2] after a method? List index or array or what?
0
votes
1
answer
22
views
How to reuse vue method for different form inputs
I am making a gaming character creator menu, which has a lot of form inputs that essentialy work the same way, incrementing an attribute up or down by one on button click.
I am fairly new to using Vue ...
3
votes
2
answers
37
views
Which magic method does hasattr call?
Which magic method method does hasattr call?
getattr(__o, name) can also be called as __o.__getattr__(name)
setattr(__o, name) can also be called as __o.__setattr__(name)
But what is the equivalent ...
0
votes
0
answers
26
views
How to make a customizad method python? [duplicate]
This might be a dumb question but I'm a beginner, how do you make your own method in python
Example the method list.clear() i want to make one that does that but it says list.NUKE
Thank you for the ...
0
votes
0
answers
7
views
Cannot retain value inside finalList variable? Firstly, fetchTracksMetaData and store result into variable finalList, so fetchLibraryTracks can use
For building a music player library, I am firstly picking the directories from where we get audio files. Then, provide the chosen directory as string to fetchTracksMetaData function, which lists all ...