Posts by Victor Stafusa • 63,338 points
1,321 posts
-
2
votes1
answer578
viewsA: After commit using Tortoise, unchanged folder icon
In Windows Explorer, open the menu using the right mouse button, submenu "Tortoisesvn", "Clean up..." And on the screen that appears, choose "Refresh shell overlays" (uncheck the other options if…
-
2
votes1
answer56
viewsA: Use vector on functions outside main
You have: crescente(&vet,10); And: decrescente(vet,10); Notice that one is with the & and the other not. The right thing would be for either of you to have that. After that, in function…
canswered Victor Stafusa 63,338 -
1
votes1
answer421
viewsA: How do I access the contents of a Jtextfield?
Maybe it’s best to use an event template. For example: public class MeuEvento { private final String nomeInformado; public MeuEvento(String nomeInformado) { this.nomeInformado = nomeInformado; }…
-
-1
votes1
answer440
viewsA: How to order a struct within a struct
You can do it: void selectionsort_AuxPerif(Aux_Perif **vetor, int tamanho) { int i, j; for (i = 0; i < tamanho - 1; i++) { int menor = i; for (j = i + 1; j < tamanho; j++) { if…
-
1
votes2
answers104
viewsA: Java2d time-based drive
Seems to me you’re running into two problems. The first problem is that although you are using System.nanoTime(), the clock of your computer and/or operating system shall not have sufficient…
-
2
votes1
answer149
viewsA: Error in my C program
"Undefined Reference to 'Winmain@16' File not found: ctr0_c. c" I mean, you didn’t set the function main nowhere. What happens is that you typed it wrong, placed it mais() instead of main(). Also,…
-
2
votes2
answers193
viewsA: Driver of the Firebird
In your stacktrace there’s this: java.lang.NoClassDefFoundError: org/apache/ws/commons/schema/resolver/URIResolver That is, your problem is not in Firebird, but in Axis 2 Jars that seem to be…
-
1
votes2
answers193
viewsA: Driver of the Firebird
Download the Firebird driver (http://www.firebirdsql.org/en/jdbc-driver/) and put the corresponding JAR in your classpath when running the application. And also, instead of…
-
3
votes1
answer305
viewsA: Rowfilter.regexFilter does not filter Date type columns in Jtable
The solution would be to use a custom class to encapsulate the Date: public class DateHelper implements Comparable<DateHelper> { private final Date date; private DateHelper(Date date) {…
-
4
votes1
answer113
viewsA: Doubts about formatting hexadecimal numbers in java for use in MD5
The answer is in the class Formatter which is used by the method String.format: The format specifiers for general, Character, and Numeric types have the following syntax:…
-
6
votes2
answers1382
viewsA: Retrieve the first elements of an Integer list
List<Integer> list = new ArrayList<>(); // Adiciona os 40 mil registros... List<Integer> list2 = list.stream().limit(10000).collect(Collectors.toList()); Perhaps, to avoid wasting…
-
10
votes2
answers510
viewsA: Why does the main method receive parameters?
Are parameters passed per command line. For example, this program: public class Parametros { public static void main(String[] args) { System.out.print("Ha " + args.length + " parametros:"); for…
javaanswered Victor Stafusa 63,338 -
13
votes1
answer1971
viewsA: How to carry out communication between Microservices (microservices)?
You will have to carry the data from one place to the other, and all these means involve one way or another, the use of sockets. The strategies you can use depend heavily on each specific case.…
microservicesanswered Victor Stafusa 63,338 -
15
votes2
answers288
viewsA: Where should exceptions be handled to display to the system user?
In the controller. Your model layer can produce exceptions if you are trying to perform any operation that is not allowed or if the operation to be performed fails. The controller then captures this…
-
4
votes1
answer169
viewsA: Indirect sorting using index vector
The trick is to create a copy of the original array (since it cannot be changed). The array B is initialized with [1, 2, 3, 4]. Each time you change two place elements in the copy of A, you make the…
canswered Victor Stafusa 63,338 -
4
votes2
answers1419
viewsA: Is there any way to know when a record was added to the bank?
In the skywalker’s response, indicated the path to place a column in the database with the type TIMESTAMP and with DEFAULT CURRENT_TIMESTAMP. Meanwhile, the guy TIMESTAMP suffers from the bug of the…
-
3
votes1
answer493
viewsA: Creating a State Machine without libraries in Javascript
A finite state machine is a machine with a finite set of states (as the name already says). It is modeled as a graph, in which the vertices are the states and the edges are the transitions. For a…
-
9
votes1
answer282
viewsA: Main location in a project with MVC pattern
You are relying on a false premise, that the whole part of the system has to be either M (model), or C (controller) or V (view). The case of main() is the most emblematic, he is none of them and is…
-
6
votes1
answer164
viewsA: Scrolling of Tiledmap
I tidied up your code and it was like this: var canvas = document.getElementById("canvas1"); var ctx = canvas.getContext("2d"); var grass = new Image(); var sand = new Image(); grass.src =…
-
3
votes1
answer86
viewsA: Responsibility to keep information of items in a class
Question: What’s in a sold item? Answer: Value and quantity. So you create a class ItemDeVenda with the value and quantity, which are doubles. Question: What exactly represents the class Venda?…
javaanswered Victor Stafusa 63,338 -
3
votes2
answers185
viewsA: How to pass an array as argument with the user defining the column number?
The problem is you didn’t declare col nowhere. Because of this the compiler will complain because mat is a parameter, but col he doesn’t know what it is. Also, in C++, if you want to set the size of…
-
9
votes4
answers16671
viewsA: Synchronous Xmlhttprequest error on the main thread is deprecated
1. Asynchronous AJAX What you are using (through the method .load) is synchronous AJAX. Instead, use asynchronous AJAX like this: $.ajax("indicadores.php?id_indicador=2").done(function(data) {…
-
1
votes1
answer486
viewsA: javax.persistence.Persistenceexception (no security manager: RMI class Loader disabled)
Your problem seems to be classpath, as notice from here: java.lang.Classnotfoundexception: javax.persistence.Persistenceexception (no security manager: RMI class Loader disabled) at…
-
1
votes1
answer799
viewsA: Using the lower triangularization method calculate the determinant of a transposed matrix
1. First minor corrections and improvements First of all, look at this: double mat[linhas][colunas] = { 1, 4, 7, 3 }; This is not a 2x2 matrix! This is a 4 position vector. What you wanted was this:…
-
0
votes1
answer54
viewsA: Selection structure, use of the for
Well, let’s try to fix your code. First thing, instead of this: if (condicao) { // Um monte // de linhas // aqui // a perder // de vista. } else break; Makes it easier to understand like this: if…
-
3
votes2
answers1986
viewsA: Diagonal matrix in java
Stayed like this: import java.util.Scanner; public class Matriz1 { public static void main(String[] args) { Scanner ler = new Scanner(System.in); int n = ler.nextInt(); int matriz[][] = new…
-
1
votes3
answers1653
viewsA: Arraylist for String with split
Try this: List<Funcionario> funcionarios = new ArrayList<>(); SortedSet<Funcionario> funcionariosPorNome = new TreeSet<>(Comparator.comparing(Funcionario::getNome));…
-
3
votes3
answers972
viewsA: Can a global pointer point to a local variable?
Memory can be divided into two areas: pile (stack) and mound (heap). Memory allocated through malloc and out of focus with free is the memory that is in mound. Already the local variables are in…
-
5
votes3
answers1110
viewsA: I have 5 threads running in parallel. How do I know when they’re all gone?
Maybe what you want is something like this: public class Main { private static Thread criarThread(final int numero) { return new Thread(new Runnable() { @Override public void run() { try {…
-
1
votes4
answers9178
viewsA: Regex to pick a text between <>
It worked for me using regular expression <(.*)>. Using the website http://regex101.com - when testing this regular expression with Joao <[email protected]>, what was captured was only the…
-
5
votes3
answers3711
viewsA: How to shuffle characters from a Java string randomly?
Abusing a little bit of regex: public static String shuffle(String s) { List<String> letters = Arrays.asList(s.split("")); Collections.shuffle(letters); StringBuilder t = new…
-
6
votes3
answers3711
viewsA: How to shuffle characters from a Java string randomly?
How about using Java 8? public static String shuffle(String s) { List<Character> letters = s.chars().boxed().map(c -> (char) c.intValue()).collect(Collectors.toList());…
-
4
votes1
answer1289
viewsA: Foreach with Lambda does not work
Until Java 7, using external local scope variables within anonymous classes would not work if they were not final: public void metodoQualquer() { int a = 5; int b = 7; Thread t = new Thread(new…
-
2
votes1
answer92
viewsA: How to pass a CPF as a parameter of the Nsdictionary type for a call with JSON and POST?
Try to change that: let parameters: NSDictionary = ["cpf":"098.748.876-32"] That’s why: let parameters: NSDictionary = ["cpf":cpfPesquisa] Or, as suggested by iTSangar in a comment, so: let…
-
4
votes4
answers311
viewsA: Creating Data Base through Stringbuilder
First, as Maniero pointed out in his answer, you left an extra parenthesis opening here: str.append("CREATE TABLE consumo ("); str.append("_id INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, ");…
-
3
votes2
answers1616
viewsA: Locating Object in a List
That doesn’t work here? private List<Atendimento> lista = new ArrayList<>(); private Atendimento buscarPorId(long id) { for (Atendimento a : lista) { if (a.getId().longValue() == id)…
-
3
votes2
answers62
viewsA: Difficulty with creating SQL query
Try this: SELECT a.cod_pessoa AS ra, a.nom_pessoa AS nome, p.nom_pessoa AS pai, m.nom_pessoa AS mae FROM pessoa a LEFT OUTER JOIN pessoa p ON p.cod_pessoa = a.cod_pessoa_pai LEFT OUTER JOIN pessoa m…
sqlanswered Victor Stafusa 63,338 -
4
votes1
answer14854
viewsA: How to make POST with parameters in Webservice REST in java?
Maybe this will help you: public String sendPost(String url, String json) throws MinhaException { try { // Cria um objeto HttpURLConnection: HttpURLConnection request = (HttpURLConnection) new…
-
1
votes2
answers335
viewsA: How to iterate an attribute with Java Reflection?
I think what you want is this, or else something very similar: /* * Method should be implemented for copying non homonyms fields. * * @param T dto is the object that will receive the values. * *…
-
3
votes1
answer482
viewsA: Change text of a Jtextarea at runtime
Your problem is that you are manipulating files within the EDT (Event-Dispatching Thread). This is the thread that AWT and Swing use to render the screen and process keyboard and mouse events, among…
-
2
votes1
answer1491
viewsA: Recursive function to remove from a headless chained list
Its function inserir seems correct, but its function buscaMenor_Remove is quite wrong. Let’s see this stretch: q = (*lst)->seg; p = (*lst); if(q->conteudo < p->conteudo){ p = q; head =…
canswered Victor Stafusa 63,338 -
3
votes1
answer111
viewsA: Why doesn’t Entitymanager have the createQuery method with typed return?
This method exists in Java EE 7 (which has JPA 2.1): http://docs.oracle.com/javaee/7/api/javax/persistence/EntityManager.html#createQuery-java.lang.String-java.lang.Class- In Java EE 6 (which has…
-
33
votes4
answers41801
viewsA: What is the purpose of the void in C?
The return void means no return. Already a type void * means a generic pointer, a pointer of an unknown or unspecified type, a pointer to anything, any memory address. They appear a lot in the C…
-
3
votes1
answer1118
viewsA: Read file in C
Use fread and fwrite. To use them, you must open the file in binary mode. The file size is obtained through fseek followed by ftell. Here is a way to insert or update the client in the file. If the…
-
6
votes5
answers3766
viewsA: Java - simple program (finding cousins) - does not run
You made some silly little mistakes. Your big mistake is that you don’t do the counter go back to zero after iterating a number on i. Because of this, after deciding that 1 is not prime, he will…
javaanswered Victor Stafusa 63,338 -
7
votes2
answers1457
viewsA: Doubt, java regular expression
First, that the Pattern is an expensive object to be created. However, it is immutable and reusable, and therefore the best is that each one be created only once each. Second, which you used in the…
-
4
votes3
answers315
viewsA: Return in methods
The parameters are one thing and the return is something else. Imagine that each method represents a work to be accomplished. The parameters are what is necessary for the work to be done (beyond…
phpanswered Victor Stafusa 63,338 -
3
votes3
answers504
viewsA: BD for distribution together with java application
Whatever your database, it will need to save the application data somewhere on your hard drive. JAR files are not designed to be modified while being read or run, they are designed to be read and…
-
5
votes1
answer576
viewsA: reverse proxy URL
Curl will perform an HTTP request to the server, and get its response. Note that this is a two-way street, because in each connection some data is sent and then received. Curl uses HTTP, which in…
-
2
votes1
answer121
viewsA: Mark unused positions on a vector
Well, there are a few solutions I see for this: 1) Use a value outside the range; 2) use an auxiliary vector for this or; 3) use a more complex data structure. Also worth knowing the Null Object…