Most voted "java" questions
Use this tag when the question refers to some resource, information, or problem relating exclusively to the Java programming language. Java is a class-based, statically typed, reflective, and execution environment (JRE) language. Java programs are compiled to bytecode and run on a virtual machine (JVM), allowing a "write Once, run Anywhere" philosophy (WORA).
Learn more…14,468 questions
Sort by count of
-
11
votes2
answers353
viewsIs that a polymorphism?
Is that polymorphism? If so, why? I think it’s because there’s no method call. Please explain to me if I’m correct or correct me. Thank you :) OutputStream saida = new…
-
11
votes2
answers3452
viewsInstantiating interface - What’s the point?
I learned in college and in all the materials I saw that the interface serves to define a pattern that classes should follow and interfaces CANNOT be instantiated. However I came across projects…
-
11
votes1
answer5003
viewsIs it correct to create a constructor method in an abstract class?
If an abstract class cannot be instantiated, can creating a constructor method for this abstract class be regarded as good practice or not? If so, why are we creating the implementation of this…
-
11
votes1
answer1208
viewsWhy String objects are immutable?
Up to the latest stable version, Java 8, type objects String are immutable. That is, any change in a String causes the creation of a new object String. This is not harmful from a performance point…
-
11
votes3
answers2425
viewsWhy in Java is the size of an array an attribute and a String and a method?
In Java, the size of a array of any object can be obtained with length, which would be an attribute. But in the case of String is length(), a method. However, if you have a array of String, uses…
-
11
votes1
answer284
viewsDoubt about the IF
Does the IF function only work with Integers or does it also work with String? I was trying to create a program that would ask if you are sure you want to create the password. You can check the code…
-
11
votes1
answer389
viewsHow to trace letters and cut them?
I have this image below. As you can see, they are together. In this case, it’s a "7", "h" and "a". It is possible to scan the image to find them and then cut them where exactly you found them? I’m…
-
11
votes3
answers10205
viewsHow to format date in full?
Is there a Java class that works with date formatting in full? For example: Input: [dd/mm/yyyy] 27/02/2016 Check-out: Twenty-seventh February 2016 I tried to: import java.util.Calendar; import…
-
11
votes4
answers1407
viewsHow to work with values that far exceed the long (64 bit) limit value
How is stored and performed operations with numbers that exceed the limit values of type long and double? How the four primary operations are done with these numbers (sum, subtraction,…
-
11
votes1
answer4373
viewsHow to popular a Jtable with own Tablemodel?
When you’re messing with swing, we almost always come across having to handle tables and populate them with some kind of information. For simpler situations, the DefaultTableModel resolves, but when…
-
11
votes4
answers870
viewsWhy can an if be redundant?
Using a method that returns a boolean the system would determine whether a number is positive or negative. So I did it this way: public boolean isPositive(float num) { boolean positive; if (num…
-
11
votes3
answers1181
viewsHow to create a filter from the words/phrases of interest to filter a particular wave from a "List"?
In my example I have two classes that are SetorInteresse and Vaga, below follows the structure of the two: Setorinteresse class: public class SetorInteresse { private List<String> setores;…
-
11
votes2
answers4166
viewsWhat is the difference between the map() and flatMap() functions of Java 8?
What is the difference between the functions map() and flatMap() made available by the API stream java 8?
-
11
votes2
answers440
viewsWhy is it not possible to modify local variables when accessed within anonymous classes?
When trying to access a local variable from a method of an anonymous class in java, we usually get a syntax error if we try to modify its content. Some Fdis suggest that we turn the variable into…
javaasked 7 years, 10 months ago user28595 -
11
votes1
answer18212
viewsWhat are the types of Scade in JPA?
I’m looking for information on the types of Scade that exist and how they work in JPA relational modeling. The guys I found explanations for were: NONE = Does nothing with the object (default) MERGE…
-
11
votes1
answer673
viewsDetect collision between corners of objects
I’m writing a game based on Breakout, but I can’t think of a way to detect the collision between the corner of the ball area and the paddle, so I can reverse the horizontal direction of the ball. In…
-
11
votes1
answer961
viewsWhat makes Kotlin a language faster than Java?
I have read in some articles that Kotlin is faster than Java, but none of them exemplifies why. [...] As fast as Java". Kotlin - Evolve your Java Code (TDC-2016) Alex Magalhaes [...] Kotlin should…
-
11
votes3
answers2941
viewsWhat is a View on Android?
The visual components of Android as EditText, Button and others, possess the Listeners to handle events triggered by actions performed by users. Therefore, in the method corresponding to the event,…
-
11
votes1
answer252
viewsIn a map/reduce in Java, should the accumulation operation generate a new object? Or can I use the old one?
I have an application that creates several objects on top of a stream of functions. And then I collect all these generated objects in a accumulator. For example, if I generated strings and…
-
11
votes1
answer118
viewsWhat are "bridge" methods in Java?
I recently had a problem with methods bridge, what occasional in an excellent answer by Victor Stafusa. But now I realize I don’t know why that method bridge have been created, nor what it means to…
-
11
votes1
answer539
viewsWhat are the main advantages of using the Java 9+ modularization feature?
From Java 9 we have the possibility to modularize our application using the so-called Java Platform Module System Before Java 9, modularization was done purely through Jars, where we had several…
-
10
votes5
answers2222
viewsWhich libraries to develop a Restful API in JAVA?
I’m a beginner in java and would like to create a RESTFUL API but I don’t know which library to use or how to use it. Can someone refer me good tutorials or some libraries for study. I would like to…
-
10
votes4
answers1546
viewsHow can I optimize a recursive method for finding ancestors?
I have a class Pessoa who owned relationships for his father and his mother (these at any time may be null). On a particular piece of my code I need to find out if one person is an ancestor of the…
-
10
votes1
answer236
viewsHow to make Dbunit recognize the POLYGON data type of Postgresql?
I have the following dominance of the type polygon in the database: CREATE DOMAIN "global".polygon AS pg_catalog.polygon; The following table using this domain: CREATE TABLE user.area_geom (…
-
10
votes2
answers3697
viewsHow to schedule releases on continuous integration with Jenkins?
I’m using the Jenkins tool for continuous integration, it’s working normally. I tried to leave scheduled to build every 3 hours, so I checked the checkbox "Build periodically" and left as follows: *…
-
10
votes2
answers3444
viewsHow to count the amount of occurrence of a substring within a string?
I have the following return: EXCEPTION,Classexception,EXCEPTION, I’d like to take the amount of times that String appears EXCEPTION using Regex. I used the following code:…
-
10
votes2
answers4750
viewsWhat are functional interfaces?
What are functional interfaces in Java? This concept already existed or emerged from version 8 of Java?
-
10
votes3
answers640
viewsWhat is the use of nested blocks in Java?
I saw something written similar to the code below. That second block in the method method has any utility? It has to be used somehow? I ran this code and it compiled and appeared only the message…
-
10
votes1
answer1565
viewsLaunch my Windows application in System Tray
I have no idea how I get my application to start with Windows 7 already in mode System Tray. That is, start with Windows and get the program icon next to the Windows 7 clock.
-
10
votes3
answers28595
viewsCalculator with Java Graphical Interface
I started working with the Swing framework, creating a calculator with the JOptionPane, and managed normally. Now I was launched the challenge of inserting buttons +, -, *, and / in the calculator,…
-
10
votes2
answers591
viewsNested class in Java
I need to have nested classes in Java. Why the following implementation doesn’t work? public class A{ private class B{ public B(){ System.out.println("class B"); } } public static void main(String[]…
-
10
votes2
answers1330
viewsURL Forwarding With Spring MVC
I want to put in my project access a page in a subdirectory of views. Type views/pessoa/criar.jsp. How can I write a controller who goes to this page? I’m using Spring MVC 3 and…
-
10
votes1
answer292
viewsScala memory leak and processes (memory Leak)
I have a fairly complex system in Scala, with multiple threads and simultaneous system calls. This system is having some problem, because busy memory grows over time. The image below shows the…
-
10
votes3
answers2035
viewsInterface or Abstract?
I read several contents on this subject, until arriving at this example: public interface Funcionario{ public void trabalha(); public void recebe(double salario); } public abstract class Geek…
java oop software-engineering interface abstract-classesasked 10 years, 3 months ago Franchesco 5,144 -
10
votes2
answers1019
viewsHow to avoid HTML Injection and XSS on . JSP pages?
In the PHP have seen uses of htmlspecialchars and mysqli. But in Java there is some way to avoid XSS and HTML Injection? I would also like to know what would be the best way (the safest): Escaping…
-
10
votes3
answers13854
viewsFill string with zeros on the left
I’m doing a work of Operating Systems and need to turn decimal numbers into binaries. So far so good, because the method below takes an integer and converts to binary. My problem is the following:…
-
10
votes1
answer3061
viewsWhen to use Interfaces
I always had the following question: When should I really use an interface instead of inheritance and what advantages can I get ?
-
10
votes1
answer164
viewsGood Practices (Refactoring) - Best way to treat one method with for within another
Personal using good Java practice how should I convert this method? I must break into various methods and within each of them do the go? public void salvarObjetos(Objeto objeto){ for(Objeto1 obj :…
-
10
votes1
answer2239
viewsIs it worth developing in Javafx for Web, Mobile and Desktop?
I’d like to know how Javafx is going, if it’s already consolidated, if it’s still a gamble.. I really liked the look and the "Write Once, run Verywhere".
-
10
votes3
answers420
viewsjava.util.Map, best implementation considering just get(Object key)
I would like to know which class to implement java.util.Map contains the get(Object key) faster. The intention is to make a mini data cache, the volume of information will be approximately 2 to 10…
javaasked 9 years, 5 months ago David Schrammel 2,310 -
10
votes3
answers115
viewsIs there any way to generalize library imports into Java?
I created inside the same package called Banco, two classes in Java: ContaSalario and ContaPoupanca. When I’m going to import these two classes into my main class, I do: import Banco.ContaSalario;…
-
10
votes1
answer10730
viewsWhat is the difference between sendRedirect and requestDispatcher.forward?
What is the fundamental difference between the use of methods response.sendRedirect("Alguma pagina"); and RequestDispatcher despachar = request.getRequestDispatcher("/Alguma pagina");…
-
10
votes3
answers31029
viewsWhat is a Servlet and what is it for?
I’ve heard a lot about the term servlet, however, I still can’t understand. What really is a servlet? What is the point? What is its practical applicability?
-
10
votes1
answer6653
viewsHow to know if Java is running in 32 or 64 bits?
Is there a command for me to use where to return if my java is 32 or 64 bits, in the Java language? Something like System.getProperty("java.version"); Something that is like that only return me if…
javaasked 9 years, 3 months ago Anderson Rodrigues 101 -
10
votes2
answers938
viewsUsing hashcode as id is good practice?
I have a short list of strings (where the strings will never repeat themselves) and would like to use hashcode as id, is a good practice?
javaasked 8 years, 11 months ago daniel12345smith 2,120 -
10
votes2
answers341
viewsError updating the entire JAVA table
I’m trying to perform a mass update to update all prices of products registered in the system, adding the value passed by the user to the unit price of the registered product, according to the…
-
10
votes5
answers12645
viewsHow to create a vector without determining its size in Java?
I have a class TesteAplicacao that is to test and a class Teste with attributes and methods. When creating a vector in Java: Teste[] t = new Teste[10];// veja que teve definir um tamanho It would be…
-
10
votes1
answer479
viewsValidate array type attribute in an annotation
When using the annotation Ordem would like to make your attribute valores mandatory. By mandatory I mean that the value of your attribute should not accept an empty array, or an array with an empty…
-
10
votes2
answers29411
viewsHow to export a DIV HTML to PDF by rederizing CSS?
Does anyone have a code that can export a DIV to PDF by rendering all the CSS of this DIV? Is it better to do this in the backend (Java) or in the frontend (Javascript)? If anyone can help, thank…
-
10
votes2
answers8768
viewsConvert float or double in real $
I have a float = 11.6 I want to convert into Brazilian currency R$ 11,60, someone knows how to do?
javaasked 8 years, 9 months ago Mateus Carvalho 1,494