Posts by Victor Stafusa • 63,338 points
1,321 posts
-
4
votes1
answer1056
viewsA: How to include . jsp file in solution?
So, let’s suppose you want to include the header.jsp inside a file called clientes.jsp (you did not specify the name, so I invented one to be able to exemplify). There are basically 4 ways to do…
-
0
votes4
answers3813
viewsA: How to check if one string is contained in another?
Man, try to elaborate on your question, I couldn’t understand exactly what you meant. Anyway, it seems to me that what you want is something like objeto.getClass().getSimpleName().…
-
10
votes4
answers8769
viewsA: How to calculate the product of the elements of an array in C
Just use a for loop to traverse the array and multiply the elements one at a time on an accumulator. The initial value of the accumulator is 1 because this is the neutral element of multiplication.…
canswered Victor Stafusa 63,338 -
12
votes2
answers4725
viewsQ: Image rotation in java
I need an algorithm to rotate an image in java. On the Internet I found a promising algorithm at this link, and I tidied it up and adapted it to use angles in degrees. It was like this: public…
-
2
votes3
answers8488
viewsA: What happens in a conversion from a char to an int?
Here is the relevant part of the ASCII table: Código Caractere 48 0 49 1 50 2 51 3 52 4 53 5 54 6 55 7 56 8 57 9 So, by taking the character and subtracting 48, you are converting from character to…
-
29
votes8
answers3054
viewsA: When to use Waterfall and when to use Scrum?
Well, I didn’t intend to answer, but here’s a comment that Francisco Junior made: If by chance any user comes only opining subjectively on the answer (as in the first comment saying to "never use…
-
2
votes3
answers1547
viewsA: Save same object multiple times
I’ve had this same problem a few times in the past. And I’ve managed to solve it. The idea is that each request uses a new EntityManager for you. What happens is that your EntityManager has a thread…
-
11
votes2
answers294
viewsA: Curiosity about equality of Integers
Because the class Integer cache values between -128 and 127. Look at this: System.out.println(Integer.valueOf("-129") == Integer.valueOf("-129")); // Dá false.…
-
16
votes7
answers31206
viewsA: How to insert data into DB with jQuery/Javascript without using PHP?
Forget about that idea. Accessing the database directly via javascript would create very serious security problems in your application, after all with a simple firebug, anyone could change…
-
1
votes4
answers4278
viewsA: Mysql performance with Innodb in large data mass table
Not that this answer exactly answers your question. But, whereas entered records are never changed or deleted and whereas you do time-based searches, then the focus of partitioning is on time. A…
-
1
votes1
answer405
viewsA: Programming logic for mounting trinary network
I think the algorithm would be something like this: 1. Se o último nível da árvore estiver cheio então: 2. Pendure o novo nó abaixo do primeiro item do último nível, criando um novo nível. 3. Senão:…
algorithmanswered Victor Stafusa 63,338 -
14
votes5
answers3496
viewsA: What are the main advantages and disadvantages of using an LL parser or an LR?
Instead of using LR or LL, use Pegs (Parsing Expression Grammars, see here and here). A PEG is defined similarly to a GLC (Context-Free Grammar), only with the following differences: A PEG does not…
-
15
votes2
answers1666
viewsA: Why should the main method dispatch the creation of the GUI to the EDT in a swing application?
AWT needs a dedicated thread because it should receive keyboard, mouse and events repaint Continuous and fast loop screen (and the Swing runs on top of the AWT). In this way, AWT could not run on…
-
5
votes4
answers3196
viewsA: What is good practice when casting an exception within if?
In my opinion, let alone context better. In general, a different context is started with { and finalized with }, and from the point of view of those who read the code, it amounts to things from the…
-
2
votes3
answers1778
viewsA: How to select rows from table A that are referenced in a column of table B?
Its biggest problem is that table B is violating the first normal form, because the field lines_id is a multi-valued field. If you can solve this, your problem becomes much easier. Anyway, assuming…
-
17
votes3
answers4153
viewsA: Why are local variables avoided in Arduino?
I researched the subject and did not find any good answer about it. The reasons I was able to raise are as follows: Programs written for Arduino are generally quite simple and there is little memory…
-
6
votes2
answers173
viewsQ: How to force the version of a Maven plugin?
I have such a Maven project, that at the time of running the build, an A plugin runs. This A plugin depends on a B plugin that is pulled, which in turn depends on a C plugin. It turns out that this…
mavenasked Victor Stafusa 63,338 -
16
votes1
answer1315
viewsQ: How does Spliterator work in Java 8?
In Java 8 (which was released in March 2014), there is a new interface called Splitter. She has a purpose similar to Iterator, but is designed to perform parallel iterations. However, even after…
-
8
votes3
answers2543
viewsQ: Unit test with database
I have an application that uses JPA 2 with Hibernate behind and for unit testing, I use HSQLDB in memory with Junit 4.11. HSQLDB is configured in a persistence.xml file in a META-INF folder. My…
-
2
votes3
answers882
viewsA: How to insert an extended value into a table in a varbinary column?
Friend, although I’m not exactly answering your question the way you expect, I think putting a column up to 400Mb per record in the database doesn’t seem like a good idea. I would only put a URL in…
-
13
votes4
answers805
viewsA: How to use Simpledateformat in concurrent environments?
The price of building the object is usually very low. Unless you are creating several DateFormats in a loop (possibly under many layers of abstraction), and the creation time of the DateFormat is…