Questions tagged as 'java'

1
answer

Is it correct to create a constructor method in an abstract class?

If an abstract class can not be instantiated, creating a constructor method for this abstract class can be considered as good practice or not? If so, what is the reason for creating the implementation of this method? Here is a snippet of code...
asked by 27.09.2015 / 03:43
3
answers

Refactoring a java class

I have a Java class that contains 1756 lines (obviously it's not all code, there are blank lines, lots of comments and some commented code in case you need it in the future) I'm implementing the MVC structure and this class belongs to...
asked by 22.10.2014 / 12:14
2
answers

block the "erase" of the screen by time of inactivity

My application works as a guide for a professional illuminator, it works passively (responds via Bluetooth to user commands in your working tool) or offline where the user can operate it manually in parallel with their tool , the issue is that o...
asked by 24.10.2014 / 18:39
1
answer

if with a matches or several comparisons?

Considering that I have a variable of type String tipoResidencia that will never be null, and that I need to run a test, the default solution is this: if (tipoResidencia.equals("CASA") || tipoResidencia.equals("PREDIO") ) But if I wa...
asked by 14.08.2015 / 22:14
2
answers

WebBrowser / Java Browser

How do I put a sort of 'WebBrowser [.NET]' into a Java project? I know there are free rendering engines like Gecko, which is used in Firefox. But I do not even know where to start, even if I get a free engine ready. I wanted a light from a...
asked by 10.06.2015 / 21:05
2
answers

Connection with the Bank falls after a certain time

I have a server where I have several web applications connected to the database ( Mysql ). The problem is that if some system is idle it loses the connection with the bank and I have to give a refresh in the application so that everything...
asked by 18.12.2015 / 14:30
1
answer

Synchronized in static methods, and non-static methods

If I have a class, where I have two methods one static and one not. Is the lock the same or not? How to do for the two methods share, the same synchronization mechanism, ie the same lock? class Foo{ public synchronized static void test(...
asked by 28.06.2015 / 23:11
1
answer

Doubts about MySQL integration with Java

I am creating a system in NetBeans, using the Java language and the MySQL database. I wrote the following code to make the connection between the program and the database: public class Conexao { private static final String DRIVER="com.mysql.jd...
asked by 21.12.2016 / 13:56
1
answer

Why use implements?

What's the difference between using btn.setOnClickListener(new OnClickListener() { and public class MainActivity extends Activity implements OnClickListener{ I've been doing an Android course and my teacher said that implements only...
asked by 27.06.2014 / 02:31
2
answers

What is the relationship between encapsulation and polymorphism?

A few days ago, I was talking to a friend about Java, and asked what part of the subject they were studying. So he replied that they were starting their studies on inheritance. As they were long overdue, I asked how they suddenly jumped to in...
asked by 22.06.2017 / 19:26