Posts by Victor Stafusa • 63,338 points
1,321 posts
-
3
votes1
answer127
viewsA: Why the compiler alerts me Anonymous new Runnable() can be replaced with lambda
This is because in Java 8 we have the new syntax of lambda Expressions which aims to simplify the need to (ab)use anonymous classes. In particular, anonymous classes that are implementations of…
-
2
votes1
answer1603
viewsA: Error: Uncaught Typeerror: Cannot read Property 'split' of Undefined
First you get an HTML element from the page: var o_Element = document.getElementById(sourceElement.id); Then you look for the "reportInfoString" in the found element. Since the Element type contains…
-
6
votes1
answer121
viewsA: PHP Source Security
I didn’t want to answer your question, but it got too long for the comments and this ends up serving as an answer. Besides, it’s not the first time I’ve seen a question like that. So there goes the…
phpanswered Victor Stafusa 63,338 -
4
votes2
answers474
viewsA: Error "'Object' does not contain a constructor that takes 1 Arguments"
In your code: class MySQLConnection : MySqlConnection In the code of the superclass: public sealed class MySqlConnection : DbConnection, IDisposable, ICloneable Basically, you shouldn’t inherit from…
c#answered Victor Stafusa 63,338 -
1
votes1
answer121
viewsA: Publish Visual basic error
Your mistake: Failed to copy file 'C: Users Rodrigo Desktop package package program bin Debug app.Publish setup.exe' to 'C:/setup.exe'. Unable to add 'setup.exe' to Web site. Unable to add file…
-
2
votes2
answers325
viewsA: Byte validation through an image bit array
In your code there’s this: if(fList[i].getName().contains("_1") && fList[i+3].getName().contains("_4")){ This fList[i] and this fList[i+3] tell me that you expect the elements in the array…
-
3
votes1
answer186
viewsA: Maven not finding java
Your JAVA_HOME and your M2_HOME are wrong. Yours are like this: JAVA_HOME="/opt/java" M2_HOME="/opt/maven" They should be like this: JAVA_HOME="/opt/jdk1.7.0_79" M2_HOME="/opt/apache-maven-3.3.3"…
-
2
votes1
answer73
viewsA: How to decode an object via URL?
This may help you. This code opens an HTTP connection and downloads the content. After that, you should only decode the result. If this doesn’t fit, please explain better what you’re trying to do.…
javaanswered Victor Stafusa 63,338 -
2
votes3
answers185
viewsA: Ifs and Object Orientation - C#
You can use a Factory thus: class ExecucaoFactory { public void IExecutor Criar(boolean condicao) { return condicao ? new ExecucaoIndividual() : new ExecucaoFinal(); } } ExecucaoFactory factory =…
-
3
votes2
answers1969
viewsA: How do I check the status code of the server http response in java?
Your question is very wide, because the answer may or may not suit you according to what you want to do, which you should explain better. However, I will try to help you in the same way. For…
-
2
votes2
answers194
viewsA: Function only returns zero
In your class ThompsonCal there’s this: Fruto fruto = new Fruto(); When the fruit is created, all its values will be initialized initially as zero! Also, you are not calling any function or method…
-
3
votes3
answers5605
viewsA: Column 'column name' in Where clause is ambiguous
What happens is that you have two columns called COD_IDENT_CLIEN (one on the table tbl_CLIENTES and the other on the table tbl_CLIENTES_AGENDA) and Mysql has no way of knowing which of the two you…
-
41
votes2
answers19996
viewsA: How is the timestamp calculated?
What is the Unix timestamp? How is this calculation made? Is there any standardization for this calculation an ISO or something like? The Unix timestamp corresponds to the number of seconds since…
-
5
votes2
answers183
viewsA: java.lang.Nullpointerexception
Note the code below: cliente = new Cliente(); cliente.setNome(JOptionPane.showInputDialog("Nome: ")); cliente.setCpf(Long.parseLong(JOptionPane .showInputDialog("Cpf: "))); try {…
-
2
votes1
answer70
viewsA: How to compare these 2 arrays inside this while?
First, instead of acertou==false, use !acertou. Second, use the method equals(char[], char[]) class java.util.Arrays. Your code should look like this: while (!acertou && errou < 8) { for…
javaanswered Victor Stafusa 63,338 -
0
votes2
answers1505
viewsA: Object of a class in another Java class
Maybe you want something like this: public class Criatura { private Criador criador; public Criatura(Criador criador) { this.criador = criador; } public Criador getCriador() { return criador; } }…
-
0
votes2
answers261
viewsA: Preparedstatement is not working
Try to do so: PreparedStatement i = conexao.prepareStatement("INSERT INTO teste (player, level_1, level_2, level_3, level_4, level_5, level_6, level_7, level_8, level_9, level_10) VALUES ('teste',…
-
2
votes1
answer86
viewsA: Include BD data in Java
You are not managing the connection and the PreparedStatement in appropriate ways, and is dropping them open. Use the syntax Try-with-Resources Java 7+ to solve this in the simplest way. Do so:…
javaanswered Victor Stafusa 63,338 -
0
votes2
answers1947
viewsA: How to use function return in Scilab or Matlab?
I don’t know anything about Matlab, but I think your show should be like this: function funcao (x) return x ^ 2 endfunction a = 2 b = 4 function integral() x = (a + b) / 2 * 0.222 f = funcao(x)…
-
1
votes2
answers758
viewsA: Nullpointerexception error when using JSF EL
The explanation is simple. In your code, you have #{pedido.id}, and the pedido is null. The result of this is that the NullPointerException is released.…
-
1
votes2
answers122
viewsA: Doubt - Logic of numbers changing places
Be it x a natural number and y another natural number which is an anagram of x base 10, being x ≠ y. To find the multiplier m which multiplied by x results in y, we have to: m * x = y m = y / x…
-
3
votes3
answers1748
viewsA: Test a constructor with more than one parameter
First your class has some problems: The methods validaData(), validaNome() and validaSexo() return a Boolean indicating whether the validation was successful or not. However, your constructor simply…
-
1
votes2
answers2111
viewsA: How do I connect a database to a JAVA application
The only thing wrong with your code is the unnecessary call to newInstance() (just use Class.forName("com.mysql.jdbc.Driver"); just). Other than that there is nothing wrong with your code. Are you…
-
2
votes1
answer764
viewsA: How to determine the size of a Jlabel?
See the method getSize() and the class Dimension: JLabel label = ... Dimension d = label.getSize(); System.out.println("Largura: " + d.width + " - Altura: " + d.height);…
-
6
votes1
answer5553
viewsA: java.lang.Illegalargumentexception error in Hibernate when working with Enum
This is your error message: Caused by: java.lang.IllegalArgumentException: Unknown name value [fisica] for enum class [com.algaworks.pedidovenda.model.TipoPessoa] This is your Enum: package…
-
0
votes2
answers109
viewsA: Nullpointerexception on Android
Here is your bond for: File list[] = file.listFiles(); System.out.println(file); for( int i=0; i< list.length; i++) { minhaLista.add( list[i].getName() ); } The NullPointerException could be cast…
-
9
votes1
answer697
viewsA: What are the packages?
The package is nothing more than a way of defining which entity owns the code and organizing the code into logical groups within this entity. Why? Mainly to avoid name collisions. Let’s assume that…
-
3
votes1
answer326
viewsA: Run method when initialize class
Let’s see your first class: class ligacao { // ... public licacao(boolean b){ // ... Here we have a build error, because the constructor name should be ligacao, and not licacao. Also, the naming…
-
2
votes1
answer78
viewsA: Build error with structs
stay The compilation error is quite clear and explanatory: ..\src struct.cpp:19:19: error: Elements of array 'main()::stay v [3]' have incomplete type And you have it in the code: struct ficha{ ...…
-
1
votes1
answer842
viewsA: Android Studio does not display English characters correctly
Hence it seems that this is what happens when you read multiple bytes and convert each byte individually to character, ignoring the fact that some characters need more than one byte to be encoded.…
-
2
votes4
answers2818
viewsA: Email falls into PHP spam box using HTML layout
Spam filtering systems are implemented by recipients' email providers, and each provider can do it in a different way. The exact criteria for classifying an email as spam or not usually are…
-
3
votes2
answers990
viewsA: Joptionpane - Error cancel button
There must be something in your code: int valor = Integer.parseInt(JOptionPane.showInputDialog("Digite um número")); Or so: String digitado = JOptionPane.showInputDialog("Digite um número"); int…
javaanswered Victor Stafusa 63,338 -
5
votes2
answers1591
viewsA: What happens when I convert String to an array of bytes?
Well, here’s what the javadoc of the method getBytes(): getBytes public byte[] getBytes() Encodes this String into a Sequence of bytes using the Platform’s default charset, storing the result into a…
-
0
votes1
answer57
viewsA: Fakehttpserver breaks when upgrading to Jetty 9
As answered in English by Joakim Erdfelt at Stack Overflow, the only way out is to upgrade Fakehttpserver. Whether by convincing the original authors to do it, or by doing it myself. Source:…
-
1
votes1
answer80
viewsA: Filter content below the main diagonal of a matrix
To take the content that is below the main diagonal of a matrix would be the elements at positions where the line is larger than the column? Yes.
javaanswered Victor Stafusa 63,338 -
3
votes3
answers1805
viewsA: Return the inverse of a vector
Try it like this: public static int[] vetorInvertido(int[] vet) { int tamanho = vet.length; int[] vetInvert = new int[tamanho]; for (int i = 0; i < tamanho; i++) { vetInvert[tamanho - 1 - i] =…
javaanswered Victor Stafusa 63,338 -
2
votes1
answer130
viewsA: Limit anagram hits - Java
You didn’t post all the code, but let’s assume it looks something like this: import javax.swing.JFrame; import javax.swing.JOptionPane; import javax.swing.JTextField; public class Anagramas extends…
javaanswered Victor Stafusa 63,338 -
3
votes1
answer57
viewsQ: Fakehttpserver breaks when upgrading to Jetty 9
I’m migrating an application that used the Jetty 7.4.5.v20110725 to the Jetty 9.3.0.M2, using the Maven. I’ve already updated the javax.servlet-api to the versão 3.1.0. But, I’m using the…
-
2
votes1
answer72
viewsA: Problem with database insertion
Your code has several problems. The first one is that when commenting on the date fields in the first SQL, it got misshapen. She waits 9 fields in INSERT, but you only pass 7. Also it was missing a…
-
1
votes1
answer270
viewsA: Content of one matrix receiving from another
You got two problems here. First, that if your matrix at the end will have only one column, then it does not need to have two dimensions, it becomes easier to work using only one: public static…
javaanswered Victor Stafusa 63,338 -
4
votes3
answers252
viewsA: Arrays not started in C
In C, all the strings have a null terminator, which is the character '\0' at the end of string. This character also occupies memory, and because of this, it is part of the string and there should be…
-
74
votes6
answers56799
viewsA: What is Nullpointerexception and what are its main causes?
The NullPointerException is launched when attempting to use the null as if it were an object. That is, when you try to manipulate the properties, fields, attributes or methods of an object, but…
-
1
votes1
answer107
viewsA: Hostings that use JSP
I do not know if I understood your question correctly, and I will try to give an objective answer, neutral and not based on opinions. But I confess that this is not one of the best answers that…
-
12
votes2
answers574
viewsA: Is it possible to have month 13 on a date in Java?
Some calendars may be 13 months, for example Igbo calendar. The main reason a lunar calendar is 13 months is that each lunar cycle is approximately 28 days (4 weeks). If we multiply 28 by 13, the…
-
6
votes2
answers428
viewsA: Is it correct to use JS to make the effects of an HTML?
What may occur is that you want to use CSS features that do not exist in all browsers currently available in the market, and in this case, you will have problems when going to a browser that does…
-
2
votes1
answer163
viewsA: Division into different methods
Let’s take a look at this piece: int digita2 = menuAcessorio(); double tamanhototal = 0; while (digita2 != 6 && tamanhototal < tamanhopulseira) { switch (digita2) { case 1: valor += 225;…
javaanswered Victor Stafusa 63,338 -
2
votes2
answers412
viewsA: Problem when changing the type of a column in the model using JPA annotation
How about trying to use that? @Column(nullable = true, columnDefinition = "TEXT", length = 10000) By the way, you didn’t say which database you used, but whatever, this length has to be within this…
-
3
votes2
answers3012
viewsA: How to go through the values of a Hashmap through a certain key?
Are you using the HashMap incorrectly. For each key there is only one value (although otherwise it is not true). So when you do this: valores.put("Id01",13); valores.put("Id01",37); The only one…
-
3
votes2
answers72
viewsA: Generic, extend to an X or Y
That’s not possible, and it doesn’t make sense. The reason is the way the MinhaClasseGenerica would be used. In this class, the T could appear as a return type of a method, a parameter, or the type…
-
1
votes1
answer292
viewsA: Collect data from a Jtable and send to a List
First, model some classes that describe what you will print and put in them a method responsible for printing them. Let’s see, a reporting of printed products has several printed products and each…