Questions tagged as 'java'

4
answers

Mounting run-time updates

When mounting SELECTS at runtime we always have the problem of knowing what might be coming or not depending on the choices made by the user. When assembling the WHERE clause we are faced with the question of adding AND o...
asked by 27.05.2016 / 19:46
2
answers

Subtract dates in JAVA in taking the difference of days

I need to calculate the day of pregnancy that a woman is, having the information of the date the woman became pregnant and the date today. I have the following statement: Date dtToday = new Date(); //pega a data de hoje Data dtEngravidou =...
asked by 01.07.2014 / 15:47
1
answer

Concatenate Strings in Java Loops - StringBuilder or '+'?

Java allows us to concatenate Strings in Java using just the '+' operator String str = "a" + "b" + "c"; It's a simple way to do the job, and much less verbose than using StringBuilder. But in cases of Loops like the one below, which appr...
asked by 27.06.2015 / 14:53
1
answer

Connection to database - MySQL and Java

I already have a local server on my machine (localhost) with MySQL running normally. From there, I would like to connect my database with Java, but ... how do I do this? Is there a Swing component that displays the fields of a given MySQL table?...
asked by 13.05.2015 / 20:10
3
answers

Working with the JPA + Hibernate cache

I have questions about how to work with objects EntityManagerFactory and EntityManager . Currently I instantiate a EntityManagerFactory for the whole system, as I only have one bank, I create only one and use it to create...
asked by 15.01.2015 / 21:14
4
answers

Best algorithm to calculate factorial

So, I'm learning to develop in Java. The teacher asked me to develop a method for the Factorial. And also show what is happening on the screen, for example: 3! = 3 X 2 X 1 = 6 In fact, I made it happen, but is there any way for the code...
asked by 02.09.2016 / 00:35
1
answer

Can the & bitwise (and) operator of Java be used for interfaces?

Interface source code snippet Comparator . Does anyone explain to me how this Comparator<T> & Serializable is handled? public static <T, U extends Comparable<? super U>> Comparator<T> comparing( F...
asked by 08.06.2018 / 21:56
1
answer

Keep background in DrawingView

I need an application to draw on a specific background, the code is working correctly, but when I go to delete / correct a wrong line, it erases the background and the background should be maintained. However, it is deleting the background image...
asked by 13.07.2015 / 16:02
1
answer

Convert String to Float with comma in Java

How do I gracefully convert String to float into java? The strings are with the Brazilian location, that is, the values come with a comma as the decimal separator ("12,345"). I think so ... "ugly" to use String prec...
asked by 26.02.2016 / 13:23
1
answer

What is the difference between the replace () and replaceAll () methods?

I was reading the documentation to properly develop a mask and save without it. However, I came across this question about methods replace and replaceAll for my string . What's the difference between the two, apparent...
asked by 03.04.2017 / 14:53