Questions tagged as 'construtor'

1
answer

How to pass arguments dynamically to a new call?

If I have a JavaScript function and I want to call it by passing a list of arguments, I use apply : var x = f(1,2,3); var x = f.apply(null, [1,2,3]); For the first time, I came across a case where I need to call a constructor with a...
asked by 15.09.2015 / 08:10
2
answers

Entity Framework and parameterized constructor

When I create domains, I usually create a parameterized constructor for it: namespace Models { public class Unity { public string Abreviation { get; set; } public string Description { get; set; } public Unity (...
asked by 27.05.2016 / 22:57
2
answers

Builders in PHP 7

I was testing a class in PHP 7, and noticed that the constructor no longer works when it is created from the class name, only working when it is created with the name __construct . Example: <?php // Assim funciona: class MinhaClas...
asked by 31.03.2018 / 02:52
1
answer

Instantiating an object in the same class as the constructor is "inelegant"?

It is always seen as a good programming practice if you create a class for the object, where we have the constructor and we make the methods and another class where we instantiate several objects of the class created previously. However, I wou...
asked by 28.12.2018 / 13:21
1
answer

What is the difference between classes initialized with (and without) __init

I'm a beginner in Python and wanted to understand a difference. The two classes below produce exactly the same result and the variables are publicly the same in both classes: class c(): t = "abc" print (t) for a in range (3):...
asked by 18.09.2018 / 00:06
1
answer

Copy and move constructors are called only in the creation of an object?

Are the move and copy constructors only called when creating an object? if yes, after the creation of an object, it is not possible to invoke either the move or copy constructor of that object, right? The doubt came from here: class En...
asked by 11.03.2018 / 13:09
1
answer

Compiler error due to lack of constructor

I have the following classes: class Disciplina : public class Disciplina { public int Id { get; set; } public string Nome { get; set; } } interface IGenericaDAO : public interface IGenericaDAO<T> { bool Ad...
asked by 23.05.2017 / 15:17
1
answer

Can you override constructors?

I think I can not, what do you have to tell me? @Override public class main (String arg[]){}     
asked by 12.05.2016 / 21:45
1
answer

Conversion difference from Array to ArrayList with "asList" and with constructor

What's the difference between these two ways of converting an array ? If there is any difference, does it impact performance? List<String> list = Arrays.asList(meuArray); ArrayList<String> arrayList = new ArrayList<String>(...
asked by 05.11.2018 / 13:52
1
answer

Java error 'constructor' X in class 'X' can not be applied to given types; "

When compiling the code below I get the following error: Exception in thread "AWT-EventQueue-0" java.lang.RuntimeException: Uncompilable source code - Erroneous sym type: Connection.ConnectionMySQL.<init> And in line public class...
asked by 12.11.2018 / 02:39