Posts by Victor Stafusa • 63,338 points
1,321 posts
-
4
votes2
answers629
viewsA: Simplification of Boolean expression
This answer is a solution by reducing boolean expressions. I also posted another answer based on truth-table analysis. The first NOR gate in the figure produces that: (1) j = NOT (a OR b OR c) The…
boolean-algebraanswered Victor Stafusa 63,338 -
3
votes2
answers629
viewsA: Simplification of Boolean expression
This answer is a solution through truth-table analysis. I also posted another response based on boolean expression reduction. Let’s see how the truth-table looks: A B C D F 0 0 0 0 1 0 0 0 1 1 0 0 1…
boolean-algebraanswered Victor Stafusa 63,338 -
2
votes1
answer755
viewsA: How to convert java.util.Date to java.sql.Date keeping up hours, minutes and seconds?
To convert from java.util.Date for java.sql.Date: java.util.Date a = ...; java.sql.Date b = new java.sql.Date(a.getTime()); To insert date and time, use the class java.sql.Timestamp: java.util.Date…
-
3
votes2
answers207
viewsA: UF field that accepts only 2 uppercase letters
How about something like this? import java.util.Locale; import java.util.Objects; import javafx.beans.value.ChangeListener; import javafx.beans.value.ObservableValue; import…
-
1
votes1
answer1495
viewsA: Run . bat by a button
In PHP, you can use the function shell_exec: <?php $output = shell_exec('seu-arquivo.bat'); echo "<pre>$output</pre>"; ?> It is important however first of all, make sure of the…
phpanswered Victor Stafusa 63,338 -
3
votes1
answer71
viewsA: I can’t get the variable value from different classes
I will not get into the merit of the numerous compilation errors of your code posted incomplete, nor in the structural problems that "doctor extends patient" cause [1], nor in the strangeness that…
javaanswered Victor Stafusa 63,338 -
2
votes1
answer161
viewsA: Problem with malloc in C when creating string concatenation function
First count how much memory you will need. Then store the memory and only then start concatenating. So we don’t have to use ft_strlen twice in each string, you can use a cache. Moreover, in the…
-
1
votes2
answers522
viewsA: How to query a bank from a thread?
To answer by Articuno is on the right track. However, separating what goes in the EDT from what goes in the thread is easier using the SwingWorker, including taking care to query the DAO outside the…
-
6
votes2
answers1764
viewsA: Progress bar plugin with steps
It took a lot to do, but here it is. Click the blue button Execute down below to see working. /* JavaScript para incluir. */ jQuery.fn.extend({ stepProgressBar: function(currentStep) { currentStep =…
-
3
votes1
answer201
viewsA: Why do normalized schematics up to 3FN not have N:N relationships?
Let’s say we want to relate which dogs have which owners and vice versa. We have that the same person can own several dogs and a dog can have more than one owner. There are also dogs without owners…
-
1
votes1
answer141
viewsA: Problem with URI issue 2144
The enunciation says: In the end, if the average of all cases is greater than 40 You’re adding up all the cases, but you’re not dividing by the number of cases, so the average calculation is wrong.…
canswered Victor Stafusa 63,338 -
3
votes1
answer263
viewsA: Why doesn’t the printf concatenate?
Your code does not compile for several reasons: You use commas to concatenate. You should use commas +. You do not close the string that starts with "xonvenio. By the way, I think you’re talking…
javaanswered Victor Stafusa 63,338 -
6
votes1
answer436
viewsA: How and when to use "Labels" in Javascript?
The Labels are to be used in instructions break and continue. They are inherited from C, C++ and Java, and also exist in many other languages such as C#, Pascal family languages, Visual Basic family…
javascriptanswered Victor Stafusa 63,338 -
3
votes1
answer2036
viewsA: @Enumerated(Enumtype.STRING) Hibernate JPA
Try using a Converter with a AttributeConverter: import javax.persistence.AttributeConverter; import javax.persistence.Converter; public enum Classificacao { POSITIVO('P'), NEGATIVO('N'); private…
-
1
votes1
answer420
viewsA: Sqlexception error while trying to connect to database
First, check that the Mysql driver is in your classpath. You can download The JAR from the 8.0.8-dmr driver here. When placing the driver in the classpath, this problem should be solved. But, there…
-
1
votes1
answer80
viewsA: Httpurlconnection returning empty
The first problem is this passage: } catch (Exception e) { result = null; } This here is not a good idea, because it will swallow the real mistake to mask it as a NullPointerException after.…
-
1
votes1
answer154
viewsA: Change file contents with ajax
Your problem is: change something in the browser, I would like to save/overwrite the changes in the original file. What you have to do is make the changes in the browser, and then send (possibly via…
-
3
votes1
answer569
viewsA: What’s wrong with my code? (URI problem 1805)
The code itself is correct, but it has a very bad performance. Such as stated above: Entree Each test case contains two integers To and B (1 To ≤ B 109), representing the lower and the upper limit…
canswered Victor Stafusa 63,338 -
1
votes1
answer1667
viewsA: Create strstr / Pointer return function in C
First we have this: aux2 = 0; aux3 = 0; Then we have this: aux3[aux2] = str[index]; I mean, you’re trying to write something on a null pointer. To implement the strstr properly, you should neither…
canswered Victor Stafusa 63,338 -
4
votes1
answer43
viewsA: Problem with do while
Before the variable escolha does not appear declared in this code. But the big problem is that you used || instead of &&. Look at this: escolha!=1||escolha!=2 Think about it, if escolha for…
-
1
votes3
answers4815
viewsA: how to install java JDK and JRE in windows 10?
Edit the item C:\ProgramData\Oracle\Java\javapath;%JAVA_HOME%\bin and let it just as C:\ProgramData\Oracle\Java\javapath. Create an environment variable called JAVA_HOME with the value C:\Program…
-
1
votes1
answer44
viewsA: Prevent repetition of an element in a part of the code
First, you can combine the two do-whiles in a single using one || to match the conditions. Second, not to confuse, instead of increasing min and summing into a variable i, let min unchanged and…
-
0
votes3
answers833
viewsA: I’m trying to get a C on file, but the code won’t let me enter the address
First, = is an allocation operator, while == is for comparison. Therefore, you should use if (opcao == 1) instead of if(opcao=1). In his else is missing a if after and has a ; further. As a result,…
canswered Victor Stafusa 63,338 -
2
votes5
answers3132
viewsA: What is the difference between comparison operators on Oracle?
According to this page of the oracle, in table 3-4 of this page: != ^= < > ¬= Inequality test. Some Forms of the inequality Operator may be unavailable on some Platforms. Translating:…
-
4
votes3
answers6982
viewsA: Calculate the standard deviation of a vector
The formula is wrong. You must take the sum of the variation of the mean squared. Here is your revised and simplified program: #include <stdio.h> #include <math.h> #define QTD_ELEMENTOS…
-
4
votes2
answers1584
viewsA: How to avoid infinite recursion without using the Jsonignore annotation in Springboot
Why it’s not a good idea to turn entities into JSON directly The error is in wanting to turn your JPA entities into JSON. I’ve been a part of a project that’s been months behind just because of…
-
6
votes2
answers430
viewsA: Deadlock at Conceptual Design Level, Entity-Relationship Modeling (MER)
You have to look at the physical model. For example: CREATE TABLE casa ( id INT, endereco VARCHAR(200), PRIMARY KEY (id) ); CREATE TABLE pessoa ( id INT, nome VARCHAR(200), PRIMARY KEY (id) );…
-
5
votes1
answer208
viewsA: Bigdecimal takes the value of a string
String a = "8"; BigDecimal a2 = new BigDecimal(a); BigDecimal b = new BigDecimal(2); BigDecimal c = b.add(a2);
javaanswered Victor Stafusa 63,338 -
4
votes1
answer4003
viewsA: Recursive binary tree and leaf sum
Here’s your binary tree class. I added in the class No and in class ArvoreBinaria the methods soma(). I also put the toString() to show the tree structure. class ArvoreBinaria { private No raiz;…
-
1
votes3
answers569
viewsA: Import a. java into another . java
You have to compile the code like this: javac Principal.java Pessoas.java Then, to rotate, do this: java Principal It is very important to have both files on the command line of javac, otherwise it…
-
0
votes1
answer55
viewsA: Is a function defined within a recursive function bad?
There is no problem in this and no cost of performance. Even this practice is used in several frameworks, such as jQuery. However, as with anything else related to programming, depending on the…
javascriptanswered Victor Stafusa 63,338 -
1
votes1
answer89
viewsA: What do the following lines of code do?
The code is not the best, starting with bad identation (but also not the worst). Looking at what it does, it’s clearly the insertion procedure in a self-balancing tree, probably (but not…
canswered Victor Stafusa 63,338 -
4
votes1
answer610
viewsA: Interfaces can be instantiated?
The only wrong detail in this example code is that the variable of the first line has the same name as the variable of the second line, which does not compile. These variables would need to have…
-
6
votes2
answers554
viewsA: What are the applications of day-to-day arrays? (examples of their usability)
Arrays are widely used in the Java language. Inclusive Strings are implemented by means of arrays. There are several methods in JDK in several classes that create or consume arrays of various types.…
-
1
votes1
answer284
viewsA: Update in mysql loop table
UPDATE aluno SET presente = 'S' WHERE numero = ? AND data = ? Or else: UPDATE aluno SET presente = 'N' WHERE numero = ? AND data = ? In the ? you enter the student’s number and date.…
sql-updateanswered Victor Stafusa 63,338 -
3
votes3
answers951
viewsA: Table normalization for 2nd Normal Form
Your tables Cliente and Agência are in the first normal form because no field is multivariate, so let’s focus on the second normal form. There are two candidate keys in the table Cliente: id and…
-
4
votes2
answers61
viewsA: Why do even numbers not have the same output as odd numbers?
Remove that line: System.out.println(" ");
-
1
votes1
answer28
viewsA: Equal fields Date between tables
Try it like this: SELECT A.*, B.* FROM TabelaA A, TabelaB B WHERE B.datab = YEAR(A.dataa) * 10000 + MONTH(A.dataa) * 100 + DAY(A.dataa) Whereas the fields you want are dataa table TabelaA and datab…
databaseanswered Victor Stafusa 63,338 -
3
votes1
answer96
viewsA: Problem in assembling a C matrix
I think what you wanted was this: #include <stdio.h> #include <stdlib.h> int main() { char i, j, m[3][3]; char tecla; //captura os elementos for (i = 0; i < 3; i++) { for (j = 0; j…
-
0
votes1
answer1002
viewsA: Calling Jbuton from one Jframe to another
Let’s do what your class buttons do Principal: private void JBAcessarActionPerformed(java.awt.event.ActionEvent evt) { String args [] = new String [1]; FrameB1.main(args); } Let’s see your class…
-
1
votes1
answer90
viewsA: PMD and checkstyle in windows 10
You may have heard that Java is a platform-independent language. So, the link to download the PMD and the checkstyle are the same on any operating system. The link to download Checkstyle 8.3:…
-
4
votes2
answers1339
viewsA: How to convert negative decimal numbers to hexadecimal
You can use a boolean flag negativo to track this, remove the signal from the number and at the end put the "-" in front if the flag is true. In addition, in the case of digits 10 to 15 (A to F), it…
-
1
votes1
answer100
viewsA: Database result in inputText
I’m going to base myself on my answer to your other question. There are two possible alternatives, to calculate the value of the next code when loading the page or using autoincrement. Loading the…
-
5
votes1
answer590
viewsA: Image does not appear in the JSP table
Where is your problem The problem is here: <img src="<%=registro.getImagem()%>" width="100" height="100" /> You haven’t shown how the method is getImagem() of your class Produtos, but…
-
0
votes1
answer310
viewsA: Error while trying to delete with DELETE method using web service Rest in Java
See the first line of your figure: There it says: GET SolicitaçãoFailed RequestFailed --> Status: (405) Notice that the first word is GET. It should be written DELETE. That is, the code that is…
-
1
votes1
answer555
viewsA: Split an array into new character limit arrays in each array
I managed to do with the function dividePartes below. Click the blue button Execute to test: function dividePartes(s) { var partes = s.split("|"); var resultado = []; var pedaco = ""; for (var i =…
-
2
votes1
answer57
viewsA: onSpinWait Java 9
That method Thread.onSpinWait() is for a thread to tell the JVM that it is in a busy waiting process. That is, it signals that the thread is inside a loop waiting for something to happen, and…
-
2
votes3
answers9910
viewsA: Remove first and last character from a string
public static String removePrimeiroEUltimo(String x) { if (x == null) return null; if (x.length() <= 2) return ""; return x.substring(1, x.length() - 1); } …
-
7
votes1
answer11590
viewsA: What is Java & quot?
You must have taken it off of this link here. " is the HTML escape sequence representing double quotes ("). That is, this text should be this: ClasseObjeto celula+""+col+"_"+lin = new…
-
5
votes1
answer1020
viewsA: The name of the dt_ultimo_access column was not found in this Resultset
Your query has the following fields in ResultSet (which is the object representing the results obtained from the implementation of query): id_entidade, id_sistema, id_pagina, id_usuario,…