Posts by Paulo H. Hartmann • 925 points
36 posts
-
6
votes1
answer77
viewsA: What am I doing wrong? Java exceptions
You’re always going through your throw, whether or not entering your if. Put him inside the else @Override public void saca(double valor) { if (this.getSaldo() >= valor) {…
javaanswered Paulo H. Hartmann 925 -
2
votes3
answers5118
viewsA: Java Tabulated Calculation, using Repeat Loops
Another example, with an external loop to be able to repeat the tab operation with other input values. public static void main(String args[]) { int A; do { Scanner tab = new Scanner(System.in);…
-
2
votes2
answers302
viewsA: Application with JBOSS Wildfly reply via DNS
You need the configuration of jboss in the briefcase WEB-INF of your project. For Wildfly to recognize the path (other than the default), add the following tag <context-root> followed by the…
-
2
votes2
answers100
viewsA: Networkonmainthreadexception error while recovering local IP from device
This Exception has been deleted as it is not possible to network operations in the Main Thread. This throw is only released for Androids newer than Honeycomb. But Google Android discourages doing…
-
1
votes2
answers87
viewsA: Return message if no checkbox is selected
Another way would be to test the size of your list Listcheck(supposing that your list is a Collection) after passing through their if addition. public void verificaCheckBox(){ Listcheck.clear(); if…
-
2
votes1
answer488
viewsA: Checkbox and Radiobutton Validation
Both in the CheckBox how much in the RadioButton there is a method that can be used to make this test, the isSelected() returning true if your component is selected. This way you can use it to show…
-
3
votes1
answer1911
viewsA: Insert Json within Json
An idea for the solution: Make the Student JSON request and mount it inside a Student object Make the requisition of Classes, according to the ids you already have. Assemble a Class object according…
-
3
votes1
answer155
viewsQ: Use a Threadpool or just start a new Thread?
Let’s say the software every time creates a new Runnable to perform a basic function at each cycle, at the end of a running day I would have a few hundred Threads of this function created and…
-
2
votes1
answer346
viewsQ: Array of Boolean for Integer
How can I transform a Boolean array, boolean[] bits in his Integer correspondent? I have a function that does exactly the opposite, but I didn’t understand it enough to be able to reverse it. int…
-
2
votes3
answers421
viewsA: Error passing from String to float and from float to String
Be sure that the value you receive as string initially can be converted into float(that your string initial corresponds to only numbers). Exchange the valorStr for your variable String corresponding…
-
1
votes1
answer183
viewsA: Selection Sort - Is that correct?
His logic is Bubble Sort, because he is always working with the next vector position. Selection Sort searches all vector positions for the lowest value and replaces the ordered index. Selection…
-
1
votes1
answer313
viewsA: Problems with JPA, @Onetoone and mappedBy
The attribute [pessoa] in Entity class [class br.com.lojagames.model.Endereco] has a mappedBy value of [post] which does not exist in its Owning Entity class [class br.com.lojagames.model.Pessoa].…
-
2
votes2
answers840
viewsA: Numbers located in odd positions
To show the odd or even value you can use as follows: valor % 2 == 0 // retorna true para valores pares valor % 2 != 0 //retorna true para valores impares Using that expression inside a if, he tests…
-
6
votes2
answers269
viewsA: Understand error message
This is because the default JVM configuration (if you haven’t changed any parameters in the installation) is around 16 MB. But there’s no way to give you a conclusive answer because I don’t know…
javaanswered Paulo H. Hartmann 925 -
3
votes2
answers185
viewsQ: Relation between bean and view
I have three views that show the same table with a sequence of leds and information, I have a class service that makes the business logic to know which led and which color to show, in my bean…
-
4
votes1
answer942
viewsA: How to save a localdate to a mysql table?
You can do it using the sql.Date generate a util.Date from a LocalDate: java.util.Date date = java.sql.Date.valueOf(localDate); And to do the reverse operation the method is used toLocalDate class…
-
1
votes3
answers126
viewsA: Doubt in CRUD, I’m having trouble reading the keyboard data
To set the fields of your object by the console you can use the class Scanner public class Principal { public static void main(String[] args) { int opc = 1; Biblioteca biblioteca = new Biblioteca();…
javaanswered Paulo H. Hartmann 925 -
0
votes2
answers2088
viewsA: Where to change the name of the project?
Inside the archive pom.xml you can find these settings, just modify: <groupId>br.com.home</groupId> <artifactId>PrevisaoVendas</artifactId> <version>1.0</version>…
-
0
votes1
answer1030
viewsA: How to load picture graphicImage primefaces into different component
You will get a call from this image on your web page: <p:graphicImage id="comfoto" value="#{PhotoCamBean.getImage()}" stream="false" /> Along with your button where confirms the image cut you…
-
0
votes1
answer98
viewsA: Mount Query to last Google Datastore record
I decided as follows: A query that returns only the codes of the items filtered by codCliente, using the functions of google cloud Projection and DistinctOn A second query that returns only one…
-
0
votes2
answers255
viewsA: Mask in Textedit
You can do it this way: public String mascaraDouble(Double myDouble){ String result = String.format("%1$,.3f", myDouble); return result; } The String.format is very rich in options, this link has…
-
3
votes1
answer98
viewsQ: Mount Query to last Google Datastore record
I’m working with the Datastore from Google and I’m unable to mount a Query to return what I need. Situation I have a Entity, keyed {"item": codItem, "item": id}, still within that Entity I have the…
-
0
votes1
answer44
viewsA: Difference in string size with Fontmetrics.charWidth and Fontmetrics.stringWidth
charWidth(char ch) Returns the advance width of the specified character in this Font. stringWidth(String str) Returns the total advance width for showing the specified String in this Font. The…
-
3
votes2
answers135
viewsA: Because the System.out.print.ln of this if is not played
If your idea is to make a new paragraph at each end of the line, you could do so: for (int linha = 0; linha < tabela.length; linha++) { for (int coluna = 0; coluna < tabela[linha].length;…
javaanswered Paulo H. Hartmann 925 -
3
votes2
answers3800
viewsQ: Long or Date in JSON
Applications, one server and several customers, POST and GET to the server exchange objects JSON. One of the variables that goes along with the JSON is the datahora atual, see different Strings to…
-
2
votes1
answer179
viewsQ: Final local variable in Inner class in Java 8
There was a modification between Java 7 and 8 versions. Where in Java 7 for a local variable to be used within a inner class should be declared final. Now compiling with Java 8, this local variable…
-
0
votes1
answer142
viewsQ: Global control for Executorservice
I run a software locally in Java SE, basically it is the synoptic of a equipment in the field, can be controlled by this software. The user has several functions within it, being able to call,…
-
2
votes2
answers888
viewsA: Working Hours Calculation - Java
I made a system similar to this one, I’ll give you my example, maybe you get some information that can help you, I had the same problem in computing the hours in different days and I ended up doing…
-
4
votes1
answer105
viewsA: Character array does not save correctly
Amendments: palavraGerada[i] replaced by palavraLida.toCharArray()[i] for (int j = 0; j < palavraLida.length(); j++) replaced by for (int j = 0; j < alphabet.length; j++) Solution: public…
-
0
votes1
answer319
viewsQ: Run class when starting web application
I have a class that would need to run along with the web application every time it starts. I would upload the application to the server and this class would need to be run. This application is…
-
1
votes1
answer246
viewsA: Cannot resolve method getcontext() or getItem()
Your Listadapter class needs to extend ArrayAdapter<Item>. Example: public class ListAdapter extends ArrayAdapter<Item> { public ListAdapter(Context context, int textViewResourceId) {…
-
1
votes1
answer356
viewsA: Error with Mysql insertion with JDBC
Your ID is a String even? If it is auto increment, do a test with this code in the location of your Resultset and your While: try (ResultSet resultSet = comando.getGeneratedKeys()) { if…
-
2
votes1
answer650
viewsQ: Test date at least one day earlier
System that controls Orders of Service, the moment I open a new service order I close the previous order. If the previous service order was opened on an earlier date (at least one day ago) I close…
-
0
votes1
answer104
viewsA: Taking Values from a range of numbers where the tens n repeat
You could turn this int for String and so compare your substring or still use a regular expression Something like this: int inicio = 0; int fim = 50; for (int i = inicio; i < fim; i++) { String…
javaanswered Paulo H. Hartmann 925 -
0
votes1
answer143
viewsA: What better way to connect to a Web server using Java Web?
As I understand it is a web server, an allocated location, with no running application that just keeps this file . txt la inside. If on your server it is possible to implement some application you…
-
1
votes0
answers48
viewsQ: Message system (GCM) for local application
I’m after some system like Google Cloud Messaging, to send notifications to a local application, a supervisory made in java, running locally (it in turn connected to a microcontroller). The idea was…