Posts by Maniero • 444,682 points
6,921 posts
-
1
votes2
answers109
views -
4
votes2
answers270
viewsA: Use a constructor with multiple parameters, or create multiple sets?
The two questions you should read first are What good is a builder? and Getters and Setters Methods (actually there is a list of questions to read). Without knowing why use these mechanisms will not…
-
2
votes3
answers58
viewsA: The result comes out another
There are numerous problems with that code. Some are more cosmetic or not so important, but this is not how you program in C. If you learn wrong will always do wrong. The comments are obvious so…
-
2
votes1
answer86
viewsA: What the hell is marshaling?
What is Marshaling? Do you know about serialization? It’s more or less the same thing. But the goal of it is to call some function from the other side so you just pass parameters or get the return…
-
1
votes2
answers48
views -
2
votes1
answer409
viewsA: What is the "super()" operator for in Javascript?
It is not an operator, it is a way of calling a constructor in a specific way, so it is a construction of the language through a keyword. It serves precisely to call the builder of the inherited…
-
1
votes2
answers143
viewsA: Instantiating a class as being property of another class
This line: public Especialidades especialidade { get; private set; } Clearly shows that you can only write on the property (set) privately (private), so if you want to write in it publicly you have…
-
2
votes1
answer90
viewsA: Multiple dispatch in Julia language
TL; DR It’s just one overload of functions resolved at runtime. If you know the types of objects at compile time do not need this mechanism (provided that the language allows solving in the…
-
1
votes1
answer47
viewsA: Sum function returns zero
This code is confusing and makes no sense. If you do the simple, doing only what is necessary according to the statement, giving more meaningful names to the variables is easier. Nor was it…
-
4
votes1
answer95
viewsA: Skip line in a function with implementation
First, let’s get this abuse of lambda where a normal function works best. If someone taught like this, run away. I don’t think it’s horrible for a code to show that it does exactly what it’s meant…
-
3
votes1
answer68
viewsA: How to create an . exe that you don’t need to run as an administrator?
In the manifest file of the application should put: <requestedExecutionLevel level="asInvoker" uiAccess="false" /> There is no guarantee that you will not ask for administrator privilege…
-
1
votes2
answers42
viewsA: Miscalculation with While
The main problem is that it is stopping when it is larger or smaller, but you want to include the value within the limit, so you have to accept when the value is equal to the limit too so you would…
-
0
votes1
answer126
viewsA: Capicua’s algorithm is not printed as it should
Perhaps the biggest reason for this to happen is probably that you are not assigning an initial value to num, It’s already starting to get messy there because it depends on how lucky the memory is…
-
3
votes2
answers58
viewsA: Why do you think the higher value?
It does not store the largest magically, this is an algorithm, so there are several steps being executed with a collection of data being input. In such a step he will analyze whether what was typed…
-
3
votes1
answer169
viewsA: Return function of the next ASCII character in C
There are several problems in the code. I don’t like the idea of allocating memory just for this, it could change directly in the already existing object. But if the exercise This we will do.…
-
6
votes1
answer94
viewsA: Why still use String instead of Stringbuilder in Java?
As many of you may already know, creating StringBuilder can greatly save the performance of our Java applications, as they are much faster than a String. They are not, there were even times that SB…
-
2
votes1
answer59
viewsA: Parentheses in a pointer to pointer
There is a operator precedence table, as you know in mathematics (multiplication and division happens before addition and subtraction). In case a code of a language has several operators. As it is…
-
1
votes1
answer73
viewsA: Identify accented letters and print a warning
I don’t want to move too much because it might be exercise that you ask to do this way. To make it so direct on main() becomes very complicated, would have to do if with break in each level, plus…
-
5
votes2
answers88
viewsA: Typescript files in version history
Depends on what you’re doing and want. If you are creating a normal Typescript application your code is in this language, these files are the source (source) of its application and is talking about…
-
5
votes1
answer2002
viewsA: What is Java 8 Optional for? How to use it?
Purpose It’s quite funny because the biggest reason to use it is to avoid exceptions, just in the language that invented abuse in its use :) When you may have a result or not, the normal way of Java…
-
7
votes7
answers12436
viewsA: Use semicolon or not at the end of the lines in Javascript?
All the good programmers I know use it. Because it’s ambiguous not to use it in some situations. And if you need to use it on some it’s weird not to use it on others. And you start to create a…
-
2
votes3
answers89
viewsA: Wrong calculation of percentage
The code has some problems, I will not talk about all, especially the organization (that would help understand the problem) and things that do not matter for an exercise, for example that float does…
-
6
votes1
answer167
views -
3
votes1
answer117
viewsA: Is it possible to force a class to implement a Java attribute?
What are you calling attribute is actually called field. I understand you learned that way because there’s too much wrong material. A private field is implementation detail and so only the type who…
-
7
votes1
answer106
viewsA: Meaning of the parentheses in the instantiation in C#
Can you understand that every so-called method needs parentheses? Even to differentiate from a field or property or otherwise than to execute? And do you know that every code execution must be…
-
5
votes1
answer73
viewsA: In C language working with strings would it be better to spend processing or memory?
It depends on what you’re doing, it’s not so simple to answer that, just looking at each case could make a decision, and everything after measuring, because it’s not always intuitive. Contrary to…
-
5
votes2
answers119
viewsA: C# properties for those who know Java
Property is only one syntax sugar for the methods getter and Setter which is commonly used in Java and other languages. So you write the access in the code as if it were a field, but you’re actually…
-
3
votes2
answers146
views -
3
votes2
answers103
viewsA: Negative print, it only prints the postives
Mainly the break is in the wrong place, and without any condition, and if one will come out this command has no reason to complicate, and duplicate the condition. And the code can be much simpler…
-
0
votes2
answers88
viewsA: How can I split a string by semicolon and take the value of each position after the while?
This code is not C++, it’s C, if you think you’re learning C++, you’re wrong, just because it compiles in C++ doesn’t mean it’s C++. If you want to do in C++ you have the option here which is much…
-
3
votes1
answer701
viewsA: How to use a COUNT with condition?
You want the function COUNT() either aggregator, or count all elements found within a data group, that group is defined by the attribute andar, then use the clause GROUP BY. SELECT andar, COUNT(*)…
-
1
votes2
answers57
viewsA: Track data count shows wrong result
There are several problems in the algorithm. One of them is that the data type used for salary is an integer and then asks to type in a floating point type. You have to reconcile the two. If you…
-
3
votes1
answer62
viewsA: Exit "while" by filling lists
You are adding this to a list and trying to save the result of the list and not the value typed into a variable. This does not work. O append() returns None and not the inserted value. You should…
-
0
votes1
answer216
views -
4
votes1
answer148
viewsA: Is there a performance problem in using many foreign keys (FK)? If so, is it bad to have foreign attributes without being FK?
The first option is really not very good, but there are cases for use. The second decreases the field size but has the same problem as the first. It does not guarantee the canonicity of information,…
-
0
votes1
answer123
viewsA: Table structure for calculating financial transactions in Mysql?
If the right code is made, with SGDB transaction on (Myisam has no transaction), there is no reason to fear, the database is there to give assurance that all tables will be updated or none will be…
-
3
votes2
answers43
viewsA: Division does not display numbers after the comma
It is dividing by an integer number, so the result will be integer, even if it is later saved in a variable of type double. First he makes the account and then he keeps it, the moment he makes the…
-
2
votes2
answers68
viewsA: How do I show the wrong input numbers?
Are you abusing the elif. It is not because it has several conditions that everything should be grouped together. It has to do this according to the need. The validation of each note should be…
-
4
votes3
answers117
viewsA: What technical obstacle for Android not support the new versions of Java
None, or almost. The biggest reason is probably cost. It is expensive to implement all these novelties. And it is clear that Google is not investing more in Java. For her you should use Kotlin. One…
-
4
votes4
answers1335
viewsA: How to use . replace() to remove Python strings
That’s basically the idea, but it’s a slightly more complicated solution than that, because if you trade the symbol for a space, it could be two spaces in a row, which would be wrong, but in some…
-
1
votes1
answer90
viewsA: Field of type ENUM empty arrow when not a valid value
Why the database treats this way? Because he decided to be that way. It could have adopted several other actions, but Mysql likes to be permissive, it’s like Javascript and other languages, the…
-
3
votes1
answer71
viewsA: "Elif" does not allow to execute what is expected
Read the description of the criteria that should be used to give the discount. It has a and there, and that’s what you should do. There are no two different conditions, there is only one composed of…
-
2
votes1
answer48
viewsA: I have dynamically stored memory of a vector in C, does not return the allocated size, why?
Cannot do this operation, the pattern you are using is suitable for array, what you’re using is not a array, though it may seem. This is a pointer to an item and you know that there are several of…
-
5
votes1
answer292
viewsA: Should we create an empty constructor in Java?
It doesn’t make sense. You know exactly why it doesn’t make sense. What you get by doing what the compiler already does for you exactly the same? In fact I go further, in most cases it makes sense…
-
3
votes1
answer125
viewsA: Where does the memory space required for each element in a C string array come from?
You don’t understand pointers. And I start by saying that not everyone has 4 bytes, this only occurs on 32-bit architectures, and this if there is no specific trick done by the compiler with some…
-
1
votes1
answer90
viewsA: Convert int to str for loop
Do not convert until necessary. vm = input("Qual item deseja ou 's' para sair: ") if vm == 's': break vm = int(vm) I put in the Github for future reference. But the most correct is to use another…
-
2
votes2
answers78
viewsA: Problem printing next 10 numbers in sequence
The biggest mistake is that it is not accumulating the texts, in each passage it changes the text, even in the last is only what is saved in the variable. The operator = assigned a value to the…
javascriptanswered Maniero 444,682 -
1
votes1
answer168
viewsA: What does the syntax " bool Operator < " mean in C++?
This is an operator’s declaration. C++ allows operator overload. Then you can write the code with the operator’s behavior for certain types. In the background you are creating a function that will…
-
1
votes1
answer750
viewsA: Recursive function to calculate the mean
Recursion is not suitable for doing this type of algorithm. In general this is asked as an exercise to learn the mechanism, but then one learns to decide on the wrong use. It is much simpler to do…
-
3
votes1
answer72
viewsA: Dual recursion in a function, how does it work?
There’s nothing special about it, recursion is not a magical mechanism full of details that you can’t see. Recursion is just a function calling another function with a single difference between the…