Questions tagged as 'java'

3
answers

How to solve the problem "The main method was not found" in a class in Java?

I created this ArrayList and at the time of execution the following message appears:    Error: The main method was not found in class   DeclarationArray.Declaracao_Array; set the parent method as:   public static void main (String [] args)...
asked by 29.09.2015 / 15:44
1
answer

How do you handle submitting a form only once?

In a Method POST form, when I click the button twice it quickly executes the submission twice. Solutions with javascript or with the spring framework.     
asked by 14.09.2015 / 16:24
4
answers

Use of setters in the constructor

I would like to know if there are any semantically speaking differences between these two constructors: public Aluno(String n, float n1, float n2) { this.nome = n; this.setNota1(n1); this.setNota2(n2); } and public Aluno(String n...
asked by 02.11.2015 / 03:20
3
answers

Read array JSON on Android

I'm having trouble reading a JSON in the format: [{"RESULTADO":"SUCESSO"}] WebClient.java: //PARA LER UM JSON, USAMOS A Scanner Scanner scanner = new Scanner (connection.getInputStream()); String resposta = scanner.next();...
asked by 04.12.2018 / 02:30
3
answers

How to perform TDD using Hibernate

I would like to know how to do TDD using Hibernate . I was informed that this ORM stores memory before writing to the possible, so I wanted to know how to test a data that is in memory. For example: do I execute the save command and test to see...
asked by 19.02.2014 / 23:33
1
answer

Get the least significant bit of an integer in Java

I'm trying to do a bit manipulation in java, but I'm having a problem. I'm storing any number in an int and trying to get the least significant bit of it, but I do not know how to do that. For example: int valor = 98; The value in bin...
asked by 11.07.2018 / 01:49
2
answers

Return day of the week from a date in the format dd / mm / yyy

I have this function that brings me the day of the week: public static String getWeek(String date){ //ex 07/03/2017 String dayWeek = "---"; GregorianCalendar gc = new GregorianCalendar(); try { gc.setTime(new SimpleDateForm...
asked by 07.03.2017 / 04:59
1
answer

How to change the border color?

How can I change the border color created by BorderFactory? import java.awt.Dimension; import java.awt.GridBagLayout; import javax.swing.BorderFactory; import javax.swing.JComponent; import javax.swing.JDialog; import javax.swing.JPanel; publ...
asked by 17.06.2017 / 02:39
2
answers

How to make code that uses string properties readable?

I have a string that uses parts of another String, how to make this code "cleaner"? Since it is very difficult to understand. String sessionHash = dirPath.substring(dirPath.substring(0, dirPath.length() - 1).lastIndexOf("/"));    sessionHas...
asked by 17.03.2015 / 19:48
2
answers

Separate each number with a semicolon (;) in Java

In a text box that has the name of the variable MMdados I put the numbers: 0;1;0 Then I created a variable String recebeMM that receives MMdados.getText(); I send these numbers to a text field that has the MM va...
asked by 21.06.2015 / 01:32