Questions tagged as 'java'

1
answer

In an MVC project, where should I leave the enums?

I'm developing a program with MVC standard, I needed to create some enum , and I left them in the Model layer, but I was in doubt about its location, what would be the correct layer to house the enum of a project?     
asked by 03.06.2016 / 21:49
2
answers

compare and remove repeated item

I have this array of objects, and I would like to go through and remove the author repeated by name, but I can not. public class Pessoa { private Autor autor[]; int cont = 0; public Pessoa(Autor autor[]) { this.autor = au...
asked by 14.11.2016 / 22:10
1
answer

How to rename a file in java

Given my code below: import java.io.File; public class App { public static void main(String[] args) { File diretorio = new File("/home/douglas/roms"); File[] arquivos = diretorio.listFiles(); for (File arquivo :...
asked by 05.11.2016 / 13:28
1
answer

When to use Collections.emptyList ()?

I thought about using List<Object> lista = Collections.emptyList(); to initialize a list. But when I try to lista.add(element) I get a UnsupportedOperationException . After searching a bit, I saw that this occurs...
asked by 17.10.2017 / 19:26
3
answers

Help with java arrays

I have the array disciplines and the current array. The current one is an exact copy of the subjects. If there are two equal strings within the disciplines array I need to delete all equal and keep only one. That is, the current should not...
asked by 16.11.2017 / 17:31
1
answer

Help image processing (background removal)

I need to create a code to perform the frames processing of a video. In case the program will scan the pixels of the image and analyze the colors of the pixels and if you find colors close to the color initially defined, you should replace it, f...
asked by 29.12.2015 / 03:48
2
answers

How to name a constraint in Hibernate / JPA?

Using the class: @Entity public class Pessoa{ @Id @GeneratedValue(strategy = GenerationType.IDENTITY) private Long idPessoa; @Column(nullable=false, unique = true) private String nome; @OneToOne @JoinColumn(name...
asked by 30.03.2016 / 14:44
2
answers

"No value specified for parameter 1" when executing PreparedStatement

I am testing insert here and the following error appears to me:   Exception in thread "main" java.sql.SQLException: No value specified for parameter 1 Dao package modelo; import java.sql.Connection; import java.sql.Prepa...
asked by 07.07.2015 / 00:08
2
answers

What is the correct way to get the device date?

This is a relatively simple question, but it has broken my mind a lot. I need to get the date and time at a certain point in my application's execution, but I do not know which is the most recommended way to do this. In some places, I have seen...
asked by 04.06.2015 / 07:09
1
answer

How to create an Exception / Custom Exception in Java

Java, brings with it several Exceptions already ready, IllegalArgumentException, IllegalStateException, RuntimeException, among others. How to create a Custom Exception in Java? I have the following method - sumAndPrint(int,int)...
asked by 28.06.2015 / 20:01