Posts by marcus • 2,131 points
36 posts
-
4
votes1
answer54
viewsA: Name in the index of an array
Try with var obj = { [var1] : { // ... } } Reference: https://stackoverflow.com/questions/6500573/dynamic-keys-for-object-literals-in-javascript According to the link, this notation is supported as…
-
2
votes1
answer134
viewsA: A generic vector only works with pointers? Why?
Types void and void* void and void* They’re actually very different types. The void means "nothingness", therefore does not occupy any space in the computer memory. Therefore it is used as return…
-
2
votes1
answer93
viewsA: Nullpointerexception when saving an object
(the problem was solved in the comments, I will create a more complete answer to get organized). First I looked at the stack trace and saw which lines of its code were pointed (there will be several…
-
0
votes4
answers634
viewsA: JPA List<Map mapping.. >
As stated in a comment, this problem is database modeling. After modeling the bank, you create JPA entities (although some tutorials of JPA and other Orms suggest otherwise...). (Option 1) In this…
-
3
votes2
answers346
viewsA: Reuse of variables
I assume that the more the code is dried, the faster the algorithm will be compiled and executed. It already left of a wrong principle. There are several complicated algorithms that run fast…
-
0
votes2
answers82
viewsA: What is the difference in the assignment of an already started matrix to an uninitiated one?
"w" is in a static memory? Yes, strings written "directly into code" are stored in a static area. You can use these strings as pointers or by copying to dynamic buffers, for example. char nome[10];…
-
1
votes2
answers252
viewsA: Scope equivalent to @Stateless on CDI
Except with the use of some extension, there is nothing 100% equivalent in CDI. Despite this, Requestscoped can serve well for many cases, remembering that Ejbs also control transactions (they have…
-
1
votes3
answers856
viewsA: How to copy a local git repository?
I don’t see why it wouldn’t work to copy the files, since there won’t be any concurrent access (and most of the files inside the . git is unchangeable even). But if you want an alternative way,…
-
1
votes1
answer108
viewsA: Sendredirect error in Interceptor
You have an infinite loop of redirects to the login page. By the logic of your if in Interceptor, you handled the cases Not the login page and is already logged in All other cases The case has not…
-
4
votes1
answer763
viewsA: Filewriter and Fileoutputstream: when should I work with each of them?
Introducing As we know, the classes Writer have an extra functionality around the classes OutputStream which is character conversion. When you use a Writer, you work with String and char[], while…
-
3
votes4
answers187
viewsA: How to not lose the "this" of the current object
It may not be very practical, but this is always associated with a calling for, not to a function statement (they tried to improve it a little with the arrow functions =>, which follow other…
javascriptanswered marcus 2,131 -
1
votes2
answers74
viewsA: Problems to generate SQL command
It seems to me that you are confusing the language of JPA/Hibernate (JPQL or HQL) with real SQL. I checked in here https://docs.jboss.org/hibernate/orm/4.3/devguide/en-US/html/ch11.html#d5e2800 and…
-
1
votes1
answer463
viewsA: Lifecycle of @Applicationscoped at Ear
I found this bug/Issue in Jboss: https://issues.jboss.org/browse/CDI-129 What it says there is that the operation was not specified completely and the decision that @Applicationscoped is…
-
1
votes2
answers634
viewsA: JSP how to include a select within a checkbox
If you are using JSP with JSTL, include at the beginning of the file: <%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %> <%@ taglib prefix="fn"…
-
2
votes1
answer1404
viewsA: How to convert a byte[] from an image to a jpeg image to load into html?
To read an image, you can use the class Imagery. The read() method receives an Inputstream. I’m not familiar with Overload that directly receives a URL (does it recognize the "protocol" date:?), but…
-
2
votes4
answers651
viewsA: display:One consumes data?
Depends. HTML is certainly loaded. But if the element contains images, iframes or other things loaded separately, the browser will have the chance not to load them while the display is set to None.…
-
20
votes3
answers2478
viewsA: How do C graphic libraries work?
To make graphics appear on the screen, there are several layering: The creators of graphics cards, motherboards, monitors define a way for these parties to communicate. For example, set the X pin…
-
3
votes3
answers557
viewsA: Unsigned int doesn’t work?
Two things are happening: first implicit conversions between int and unsigned int (if you activate all compiler warnings, it is likely that it warns you that the code is kind of "weird"); second,…
-
0
votes1
answer232
viewsA: Return null JSP
If the input is called name="txtQtd1", your bean needs to have a method called setTxtQtd1 but in your code it’s called setQtde1. I saw that the field name in the class is correct txtQtd1, so it must…
-
1
votes1
answer184
viewsA: Program crashes after stack allocation and call in C
Did you compare the code generated by the compiler to the code you wrote? If you paste the generated Assembly here, it may help. Anyway before calling a function you must allocate space in the stack…
-
1
votes3
answers5197
viewsA: Definition of EJB
What made me really understand was this site: http://entjavastuff.blogspot.com.br/2011/02/ejb-transaction-management-going-deeper.html To make the idea more concrete, the article focuses on one…
-
10
votes2
answers1215
viewsA: Why create an interface for each DAO?
This depends more on "technology around" and plans for the future, and is not necessarily a general rule. For example, what do I mean by "technology around"? If you are talking about Java, it was…
-
4
votes2
answers216
viewsA: Loop End Error (Bug delete with char*)
See the line: cin >> n; The variable n is char*, so the >> operator thinks there is an array allocated there, and reads things that do not fit in the buffer ("-1" has 2 chars). There’s…
-
4
votes3
answers1517
viewsA: What to do when I get a bad_alloc error?
My list of options is as follows:: In everyday situations (non-critical), abort the program due to lack of memory is what you can do (preferably by saving a log). That’s what happens on cell phones.…
-
0
votes2
answers1886
viewsA: Gets function on Linux
Just using gets() is already a mistake :-) No, I’m not being the boring guy in the class, really this function has no place in the current programming and has already been officially removed from…
-
9
votes3
answers553
viewsA: In Python, what are the consequences of using is instead of '=='
Bacco’s answer is supercomplet, but for those who want a more concise answer: The is serves to compare if two things are exactly the same object in computer RAM memory. Already the == makes a…
-
15
votes3
answers1089
viewsA: What are the pros and cons of indexing vectors by zero or one?
It is possible to enumerate advantages and disadvantages of each indexing style. But honestly, if someone says a way is much better and the other is one rubbish, this person is a bit fanatic...…
-
2
votes2
answers517
viewsA: Problem loading file to memory
Looking fast at your code, I realized this: std::string name; name = "1.txt"; asset_mgr->addFile(name.c_str()); name = "2.txt"; asset_mgr->addFile(name.c_str()); You have only 1 string named…
-
1
votes2
answers1131
viewsA: Pass JSP variable value to JAVA
It depends on how you are going from JSP to Java. If it is a simple function call between <%> or ${}, it is a normal parameter passage. If it is a forward use the scope request. If it is a…
-
17
votes5
answers12967
viewsA: Why is the use of GOTO considered bad?
Prior to structured languages, there were languages that contained basically 2 decision/control structures: if and goto. In addition, they could have the maximum function feature and loop for, and…
-
4
votes3
answers2053
viewsA: Why do 64-bit versions of programs have better performance, stability and security?
The answer is in the question link itself: The Chromiun Blog - Try out the new 64-bit Windows Canary and Dev Channels. The speed increase is not only because it is 64 bits, but because the x86-64…
-
1
votes2
answers291
viewsA: Error when instantiating an object
It means that a NullPointerException on line 9 of the Seller.java file Solution: Don’t cause a NullPointerException :-) Tip: anythingVariable.anything() cause Nullpointerexception if…
-
12
votes3
answers15042
viewsA: What is the difference between BOM and BOM encoding files?
BOM (byte order mark, byte order mark) was created to solve a UTF-16 problem (and also the UTF-32, although this format is little used to save files). As each character in UTF-16 is composed of 2…
character-encodinganswered marcus 2,131 -
2
votes3
answers910
viewsA: Error in fgets function
As I was already writing comments a little complex in the other answers, I decided to add mine. I am using 2 separate variables, one to store characters and one to point to the desired array…
-
7
votes5
answers10429
viewsA: How to exchange the value of two variables in Java?
It is possible to use an auxiliary function like this: int returnFirst(int x, int y) { return x; } int a = 8, b = 3; a = returnFirst(b, b = a); // Leia como a = b; b = a; System.out.println("a: " +…
-
9
votes5
answers10429
viewsQ: How to exchange the value of two variables in Java?
You can create a Java function that changes the value of two variables without having to declare a temporary variable? For example: int a = 8, b = 3; if(a > b) { // algo aqui, sem declarar uma…