Posts by Victor Stafusa • 63,338 points
1,321 posts
-
3
votes2
answers811
viewsA: How to create sublists with numerical elements that are in a sequence?
Initially the question did not specify the desired language, and so had done only in Javascript. Now that the author specified that he wants Python, I have implementations in Python, Javascript and…
-
5
votes3
answers972
viewsA: Operation of the switch case
No. In Java, the switch only works with constant values in cases. Other dynamic languages such as Javascript can use variables in cases, but Java does not. One of the reasons is the way the switch…
-
0
votes2
answers2673
viewsA: Remove tab(tab) from sweeping
Try to use this: SELECT guia, convenio, nome, TRIM(REPLACE(matricula, '\t', ' ')) FROM tabela WHERE guia = '142' GROUP BY guia, convenio, nome, TRIM(REPLACE(matricula, '\t', ' '))…
-
0
votes4
answers5888
viewsA: Select with multiple Left Joins Sql Server
Not considering the possibility of restructuring its tables, it is quite likely that the LEFT JOIN is the best alternative after all. Also, you should only be concerned about performance in this…
-
2
votes1
answer197
viewsA: Organize groups
Simplifying the code Let’s take a look at your code. See this import: import java.awt.List; That is not the list you want to import. You are not using this List for nothing, but what you really…
javaanswered Victor Stafusa 63,338 -
3
votes1
answer178
viewsA: Arraylist repeating itself
I suppose your controller has a field like this: private List<String> listaNomeProjeto; And that it has been initialized properly somewhere. When you call the method viewCadastro(Model model)…
-
5
votes2
answers2038
viewsA: Find Xpath in Selenium
If your idea is to get to the <div id = "idtable">, you can get there directly using just this: //div[@id='idtable']…
-
17
votes5
answers2766
viewsQ: What HTTP code should I use when I can’t authenticate to third-party services with login and password provided by the client earlier?
I am implementing a service from a website that does the following: My website (A) connects to some external services provided by third parties (B, C and D) using webservices. In fact A is a REST…
-
18
votes4
answers1173
viewsA: What does the regular expression "/(?=(?:...)*$)/" do in detail?
Well, let’s build that regular expression: . - Recognizes any character. ... - Recognizes any three characters. (?:...) - Group without capture of any three characters. Groups without capture are…
-
5
votes1
answer2516
viewsA: Code that calculates days between two dates without using the datetime module
Your code has some strange things. The first is about the dubious name chosen for most variables (e.g.: Datas, Datas1, Datas2 and Datas3). I will rename them. And by renaming, I will take into…
-
1
votes1
answer107
viewsA: How do I move a triangle around the corners of the screen using java?
I think tracking down variables on which of the edges the triangle is or isn’t is much easier. In addition, it is better if the three vertices are treated equally in this regard without it being…
-
2
votes1
answer3986
viewsA: How to put three points in a word if the text overflows the page?
Add the following CSS properties to your div: .sua-div { overflow: hidden; text-overflow: ellipsis; }
-
1
votes1
answer138
viewsA: java.net.Bindexception: Address already in use /127.0.0.1:13444
This problem is because Tomcat (or some other program) is already running on port 13444 and a second instance of Tomcat has also started running on port 13444. Each TCP port can only be used by one…
-
1
votes1
answer111
viewsA: Difference of Session in Java
The annotation javax.faces.bean.SessionScoped should be added to ManagedBeanJSF s to denote that the bean has a session scope. That is, that the bean instance is maintained in the session. For…
-
14
votes2
answers301
viewsA: Contest Question: Java code about over-writing methods
There are compilation errors in this code: Within the method ml() of A, the method mx() invoked does not exist in class A. I think it was for the method mdx be called mx. In the main is being…
javaanswered Victor Stafusa 63,338 -
5
votes1
answer620
viewsA: Traversing Dates using Calendar
One detail I found suspicious is that in for, you are incrementing days, not months. On any day other than a 01 day, the iteration of the for will do nothing, just jump day after day. Also, the…
-
2
votes1
answer102
viewsA: SQL tags in query
This is from JSTL, which is a JSP technology. The JSP (Java Server Pages) is the standard Java technology for producing HTML pages and dynamic websites. Jsps are compiled for Servlets by a special…
-
3
votes1
answer380
viewsA: Calendar is not working properly
I tested the following program: import java.util.Calendar; import java.util.TimeZone; public class TesteCalendar { public static void main(String[] args) { Calendar data = Calendar.getInstance();…
-
28
votes2
answers5048
viewsA: What is a context-free language?
There is a hierarchy defined by Chomsky and refined by other researchers regarding the structure of languages denoted by sequences of symbols, words, letters, etc. This structure contains the…
-
0
votes1
answer133
viewsA: Synchronous webservice
Your question seemed confusing. But if I understand well what you want is that the method can not be running twice at the same time even by different customers. Therefore, the use of a block…
-
2
votes1
answer162
viewsA: I have a list and how do I display all the elements?
Note this code: public static List<Agente> getA(){ List<Agente> lista = new ArrayList<Agente>(); Agente agente = new Agente(); agente.setQuantidade("2"); agente.setQuantidade("5");…
javaanswered Victor Stafusa 63,338 -
1
votes1
answer106
viewsA: Java array problem to read from database
The problem you are reporting Look at this, here the array is null: int[] id_tronco = null; If he is null, then what will happen here? id_tronco[Integer.parseInt(rsExten.getString("operadora"))] =…
-
2
votes1
answer491
viewsA: Mysql in Java Desktop applications for multiple establishments
Depends what you want. If each establishment must have its database independent, then the database is installed on a physical server within the establishment and the terminals connect to it via an…
-
5
votes1
answer1435
viewsA: What’s the Youtube show for?
The serialVersionUID is used to track the compatibility of serialized versions of the classes. This is because if you serialize an instance of a class X and saved in a file, and some time later…
-
0
votes1
answer60
viewsA: Error when passing a structure by reference in C
Your code has a lot of build errors and a few more warnings. Let’s take parts. First, change these lines: init(&actors); i = check(&actors); if (i != -1) enter(&actors, i);…
-
1
votes3
answers1781
viewsA: How to validate a double field?
Try to change that: if(valor.equals("")){ JOptionPane.showMessageDialog(null, "Campo Valor não pode ser vazio","Erro de preenchimento", 0, new ImageIcon("Imagens/cancelar.png")); return false; }…
-
1
votes1
answer677
viewsA: Problem to insert a graph
1. The simplest problems First, you shouldn’t wear this: #include <conio.h> This is not a standard library. In function ìnserir, you have the following: if ( v==w || a->w == v ) Meanwhile…
-
3
votes2
answers547
viewsA: Format java.time.Duration for String
Another way of doing, complementing the response of diegofm, is you go subtracting the date fields one by one to remove from it, each component. For example: import java.time.Duration; import…
-
4
votes1
answer162
viewsA: How to optimize Tictactoe in HTML5
Your code has a lot troublesome. Document structure The first problem lies in this: <?php include 'header.php'; ?> That then will copy and paste the header.php whole in this place. It turns…
-
3
votes1
answer93
viewsA: How to capture only the first part of a text that fits in regex?
I see that in your text, the different addresses are separated by semicolons. This makes the task very simple: import java.util.Arrays; import java.util.stream.Collectors; public class Enderecos {…
-
9
votes4
answers6341
viewsA: What is the Assembler?
Assembly is a programming language. But it is not a typical language. It is characterized by being a low-level programming language composed of rigid and simple format instructions that do not allow…
-
2
votes1
answer115
viewsA: Export Mysql database with foreign keys
Myisam has no foreign keys and does not impose referential integrity. That means you can’t pull foreign keys from your database simply because they’re not even there.
mysqlanswered Victor Stafusa 63,338 -
12
votes2
answers418
viewsA: How does a Java Virtual Machine written in Java work?
First, to make a compiler of the X language written itself in the X language, do this: Using the Y language, encode and Compile a C compiler1 for the X language, which produces executable code on…
-
1
votes1
answer318
viewsA: Doubts Assembly mips
The AND and the OR is to do an operation between two registers, placing the result in another registrar. For example: and $a0, $a1, $a2 That puts in $a0, the result of $a1 AND $a2. Already the ANDI…
-
3
votes1
answer618
viewsA: Euclidean Division
Imagine we want to split chocolates for children so that each child receives chocolates and above chocolates at the end. If we have to , then those Remaining chocolates, we could get more chocolates…
-
3
votes2
answers350
viewsA: How do I create a . bat file through a . bat file?
echo qualquercoisa > qualquerarquivo.bat
batchanswered Victor Stafusa 63,338 -
1
votes2
answers5541
viewsA: Expected BEGIN_ARRAY but was BEGIN_OBJECT at line 1 column 2 Com Webservice JAX-RS e Android Retrofit
Add the following classes, both on the server and on android: public class ConjuntoFilmes implements Serializable { private static final long serialVersionUID = 1L; private ConjuntoFilmesInterno…
-
10
votes3
answers10183
viewsA: What is the difference between UNIQUE and PRIMARY KEY in Oracle?
PRIMARY KEY defines the primary key of the table. That is, what set of columns should identify a tuple uniquely and unambiguously. In addition, the table is usually organized internally according to…
databaseanswered Victor Stafusa 63,338 -
0
votes2
answers1268
viewsA: Search in a table in Mysql with Java
The first problem with your code, as others have pointed out, is this: '%"+pesquisar+"%'" What you wanted was this: '%"+pesquisar.getNomeLivro()+"%'" Another possibility is to exchange this: public…
-
4
votes2
answers104
viewsA: Problems with extensive algorithm
First of all, instead of using this pile of ifs mischievous and hideous, use math. Imagine if you wanted to do this program for numbers from 1 to 1,000,000,000? It would look monstrous! Second,…
-
3
votes1
answer3069
viewsA: What is the advantage of using Bufferedimage for images?
The interface Image is the one that models the behavior of objects that represent images in Java. The class BufferedImage is an implementation of Image which corresponds to images represented by a…
-
22
votes3
answers2628
viewsA: How to optimize this function for Fibonacci sequence?
The Fibonacci sequence generates numbers that grow very quickly. It turns out that the way you’re doing, each recursive call will create other recursive calls that create other recursive calls that…
-
1
votes2
answers1536
viewsA: Format Date Return with Date and Non-string Format
You can use Hibernate 5 with the Hibernate for Java 8. So, in your case, just change the field type inicioAtividades and the return of the getter to java.time.LocalDate. Even if you can’t change the…
-
28
votes2
answers3404
viewsQ: How do I migrate from Date and Calendar to the new Java 8 Date API?
Until Java 7, we had the classes Date and Calendar to represent dates. To convert them to Strings, the easiest way was with the use of SimpleDateFormat. Java 8 has introduced a new date API. How can…
-
30
votes2
answers3404
viewsA: How do I migrate from Date and Calendar to the new Java 8 Date API?
Legacy API problems The classes java.util.Date and java.util.Calendar, as well as the subclasses java.util.GregorianCalendar, java.sql.Date, java.sql.Time and java.sql.Timestamp, are notorious for…
-
5
votes1
answer74
viewsA: Initialized but Null Vector
I’m sorry to be so blunt, but your code is too full of problems. The cause of his NullPointerException that’s it: public void Roteiros() { // ... } Do not put void in the signature of the…
-
3
votes1
answer245
viewsA: What is the difference between using Swingutilities.invokeLater(Runnable) and Eventqueue.invokeLater(Runnable) when calling a window?
There is no none difference. THE SwingUtilities.invokeLater(Runnable) only forwards to the EventQueue.invokeLater(Runnable) directly. Look at this directly from the source code of the class…
-
1
votes1
answer470
viewsA: Nullpointerexception Selectonemenu [JSF + PRIMEFACES]
Dude, I redid your whole DAO: public class CarrosDAO() { private static final URL_DB = "jdbc:oracle:thin:@172.30.0.25:1521:desv"; private static final USUARIO = "rodrigoscs"; private static final…
-
0
votes1
answer208
viewsA: Hibernate error while running web project
The error message is very clear - the column accessusername of your select does not exist, but the column access_user_name exists. So, what you have to do is fix your SQL query by correcting the…
-
4
votes1
answer315
viewsA: Doubt when taking Map’s value
The HashMap does not offer any guarantee as to the order of the elements. The elements there may end up being removed in any order. However, if you use one LinkedHashMap instead of a Map:…
javaanswered Victor Stafusa 63,338