24 questions
0
votes
1
answer
146
views
Cpp compiler chooses the wrong constructor [duplicate]
Got a parametrized constructor which accepts size_t variables, and therefore should be called when trying to create an object passing a size_t variable. Instead, compiler tries to call the ...
2
votes
3
answers
457
views
Why do we still need to implement 'noArgsConstructor' if Java gives a non-parameterized constructor by default?
In Spring boot if we are creating a POJO class and we end up creating only a parameterized constructor and not any default constructor then Java will throw errors, why does this happen if Java ...
0
votes
0
answers
78
views
What does `const&` mean in `const char* const& _str`? [duplicate]
This is a constructor of class MyString:
MyString(const char* const& _str = nullptr);
Inside it, we give const char * and then again const& and then _str, what does const& mean here?
1
vote
0
answers
76
views
Using a constraint with a parmeterized constructor in Spring Boot application
I have a Spring Boot application where an interface has a constraint:
@Constraint(
validatedBy = {
MyValidator.class
})
public @interface MyInterface {
...
}
I'm using Togglz to ...
4
votes
1
answer
164
views
Julia parametric constructor and incomplete initialization
I'm new to programming in Julia (I'm coming from Java) and some Julia concepts are still difficult to understand to me. What I intend is to replicate this Java code:
public class Archive<T extends ...
1
vote
0
answers
41
views
Proguard doesn't keep access modifier in parameterized constructor
I have following class A
Class A {
public A(String param1, String param2)
// body
}
public A(String param1, String param2, String param3)
// body
}
}
My proguard settings
keep 'public ...
0
votes
2
answers
249
views
Creating a parameterized constructor to determine upper bound for randomized side lengths
Im working on a project for class and we have to create a Triangle class that will hold the lengths of each side of the triangle. I created a default constructor that gives each side of the triangle a ...
-2
votes
1
answer
611
views
Different ways to initialize object field with parameter [closed]
What other ways are there to initialize the class field "fieldList" based on a given List object?
One way would be Parameterized constructor.
class ObjectA {
private List<String> ...
-2
votes
2
answers
652
views
If final variable is initialized in parameterized constructor dynamically, then it breaks final rule
If final variable is initialized in parameterized constructor and data is assigned through constructor args then final value seems to be changing here for every object.
public class Test {
final int ...
1
vote
0
answers
124
views
Parameterized MVC6 WebApi constructor not calling using Ninject
I am Using MVC6- WebApi Parameterized constructor not calling. I referenced Ninject the below reference.
http://sudiptachaudhari.com/dependency-injection-aspnet-webapi/
WebApi Controller
public ...
1
vote
1
answer
60
views
when is it obligatory to define constructors in subclasses?
trying to inherit array adapter class it gives me an error when not defining a constructor in subclass....why should I define a constructor
public class WordAdapter extends ArrayAdapter<word> {
...
1
vote
2
answers
4k
views
Pytests: getting error function uses no argument error
I have following code:
@pytest.fixture
def mock_path_functions(mocker, file_exists=True, file_size=10):
mock_obj = mock.Mock()
mock_obj.st_size = file_size
mocker.patch("os.path....
-1
votes
1
answer
423
views
Why default constructor is not provided by compiler when class contains parametrized constructor defined by user? [duplicate]
I am a newbie in java and was wondering "Why default constructor is not provided by compiler when class contains parametrized constructor defined by user?"
2
votes
2
answers
1k
views
Instantiating class with interfaces in c#
Hi this might be trivial but I am trying to understand the class instantiation using interface. So below is my code:
public interface IRepository
{
string GetMemberDisplayName();
}
public class ...
1
vote
1
answer
563
views
NUnit: How can I set name of test depending on parametr in [TestFixture(typeof(param))]
I'm using NUnit + Webdriver + C#. Setup class has next stucture:
[TestFixture(typeof(InternetExplorerDriver))]
[TestFixture(typeof(ChromeDriver))]
public partial class SetupBase<TWebDriver> ...
4
votes
2
answers
10k
views
Java Optional.orElseThrow signature explanation
I looked at the Optional class method orElseThrow out of curiosity and I got confused of its signature. I didn't understand why it has to be declared as it is. So, I did an experiment with a copy of ...
7
votes
1
answer
155
views
Using role signature in mixins
There seems to be a problem in using the signature given to a role in the roles you want to mix-in. Minimal example:
#!/usr/bin/env perl6
role by-n[$n=1] {
method multiply(Str $str) { return $...
1
vote
2
answers
92
views
instantiating parameterized class
Just wondering if this is the right way to do it. I want to construct instances of my parametrized class where one of the instance variables is a generic type. The code below works but I get a lot of ...
0
votes
1
answer
90
views
Eclipse error during compilation of a parameterized contructor code
When I write a simple parametrised constructor program, it compiles and runs in the command line.
However when it is executed within the Eclipse IDE, I received the following exception:
Exception ...
3
votes
1
answer
246
views
How to change parametric type during instantiation in Julia
I'm trying to do the following
type Foo{T}
x::changeType(T)
end
where the function changeType changes the type parameter to some other type. It doesn't have to be a function, I'm happy using a ...
0
votes
2
answers
3k
views
Nested class cannot be cast to java.lang.reflect.ParameterizedType
I am trying to implement model structure like this:
Generic (abstract)
TplInsurance (extends Generic)
TplInsuranceDoctor (nested class in TplInsurance extends TplInsurance)
Unfortunatelly I am ...
3
votes
2
answers
305
views
Parametrized types in OCaml
I have searched for some time and I can't find a solution. It's probably a simple syntax issue that I can't figure out.
I have a type:
# type ('a, 'b) mytype = 'a * 'b;;
And I want to create a ...
0
votes
1
answer
796
views
My h:inputText value is not validated when it is bound to a field of some instance of a parametrized class gathered from a HashMap?
I am trying to do some "custom lightweight" JSF component binding. In my bean (controlling some JSF page) i'm declaring a HahsMap where keys ranging over my h:inputText ids (appearing in the page) map ...
1
vote
9
answers
12k
views
Any way to call the default constructor from a parameterized constructor?
Suppose, I have the following code
class C {
int i;
String s;
C(){
System.out.println("In main constructor");
// Other processing
}
C(int i){
this(i,"...