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
-
5
votes1
answer393
viewsJPA - Registry error not found right after insertion
A question about JPA procedures, because of a mistake that happened and I’m not getting it. I’m taking care of a part of the system that feeds a card order table. It searches if the user that the…
-
5
votes1
answer80
viewsView recursive calls in eclipse
Is there an eclipse tool that shows recursive calls like in this image? Where I can see the details of preference graphically?…
-
5
votes4
answers334
viewsAdvantages of Inner Class
Since I started programming for Android (I believe due to Google examples), I have a habit of creating internal classes for functionalities related to Activity. Example: If the Activity connect to…
-
5
votes4
answers9539
viewsHow to convert a string to date or date?
I have here the statements I need to convert from string to date, can help me? ObjAl.setDataEmissao(TxtDataEmissao.getText()); ObjAl.setDataNascimento(TxtDataNascimento.getText());…
-
5
votes1
answer1392
viewsHow to use redirect methods with Java Servlets
Hello, I have a page ordem_servico.jsp with a form that when submitted goes to Servletinsertordemservico which inserts the form data into the database. I am trying to make sure that when the data is…
-
5
votes1
answer615
viewsWhat does the term "String... string" mean in java?
What the term means String... string in Java? And how to elaborate a method that returns a String... as an example: public String... getStrings(){ return String... s;) } I know it’s not like that,…
-
5
votes2
answers10187
viewsGenerate Boleto in Java
I stuck here looking at some libs for bankroll generation and it seems that most have been abandoned. I wonder if there are any updated, better or easy to customize. Analized libs: Bopepo -…
-
5
votes1
answer1457
viewsMethod does not override method from its superclass
I’m new in Java and I’m learning app for Android and on my way, I ran into this mistake: Method does not override method from its superclass The word @Override is underlined in red, but I could not…
-
5
votes2
answers4930
viewsWhat is the difference between Math.Random and java.util.Random?
What’s the difference in using the random without the import, right in the method. public class random { public static void main(String[] args) { int x = (int) (Math.random() * 10);…
-
5
votes3
answers394
viewsWhat does it mean to assign Math.Random() > 0.5 to a variable?
What does that mean Math.random() > 0.5; in a boolean? Here is an example: class Pro { public static void main(String[] args) { int numero = 10; boolean[] array = new boolean[numero]; for(int i=…
-
5
votes2
answers1382
viewsRetrieve the first elements of an Integer list
I have a list ArrayList<Integer> list = new ArrayList<Integer>(); where I have over 40,000 records. I wonder if there’s a way to get only the first 10,000. I know you can make one for…
-
5
votes1
answer1084
viewsRedirect System.out.println output to Jtextarea
I’m having trouble making this redirect, let’s explain. I own a class called Engine.java, this class is responsible for doing my processing and in it has all the System.out.prints process, the…
-
5
votes2
answers2039
viewsWhat is a hook method?
I am studying some design standards and came across this method, however, its concept was not clear to me. What the method does and how it relates to the Template Method? I’d like an example in…
-
5
votes2
answers103
viewsDoubt in inheritance
I have a question about inheritance. I have the following code: public class CovariantTest { public A getObject(){ return new A(); } public static void main(String[] args){ CovariantTest c1 = new…
-
5
votes1
answer203
viewsSWT using DATETIME problem in saving compatible SQL format
The problem is this: I have a personal finance program that will register some important data, among them the registration date and the due date. Program interfaces are made in Eclipse at SWT, and…
-
5
votes2
answers1863
viewsWhat is the purpose of the default when used in the signature of a method?
Within the interface List<E> of Java there is the method replaceAll() the purpose of which is to replace all occurrences of a specified value of a list. However, in his signature he uses the…
-
5
votes2
answers7033
viewsWhat is to bind?
I can’t find the meaning of Bind to explain to me what this is. I would like an example of Bind with the same java language.
-
5
votes2
answers2528
viewsSearch for tree depth
I’d like to develop an algorithm that searches for depth in a binary tree, but I’m not getting it. When we make the tree we assign to each node the cost (cost to transition from one node to the…
-
5
votes1
answer1173
viewsRedirect to another page only if the user is authenticated
I have a login screen where I authenticate a user, but when I put one action to switch page regardless of whether the user was authenticated or not the page opens. My question is to know where I…
-
5
votes1
answer1807
viewsShow textfield or textarea java
I can’t show words in textfield (or textarea) in my code, several hours in this and I still can’t. I got a link to the code. The most important lines are these, but if you want to test the whole…
-
5
votes3
answers13820
viewsCalculate age per day, month and year
I’m trying to calculate the age per day, month and year but I’m not getting it. I followed some examples but they all go wrong too. For example if the date of birth is 14/06/1992 this method returns…
-
5
votes2
answers612
viewsAccess items from a stack using for
I’m trying to access a forward position in the pile to make a comparison, but it’s not working and I couldn’t understand this for. Code for ( String UmToken : PilhaTokens) {…
-
5
votes1
answer718
viewsHow to destroy a Session in java?
To invalidate a session, my teacher passed the following code: HttpSession session = request.getSession(false); if (session!=null){ session.invalidate(); } But after the logout, when I click Back in…
-
5
votes2
answers337
viewsNo data in Json Array on Android
I’m having a problem bringing data into an Array on Json. It seems that it does not run Try catch, but in the result variable it brings all the data. I would like to take the name field, but it does…
-
5
votes2
answers676
viewsHow to access the SDCARD on Android 4.4(API 19)
Currently I have an application running on 100 phones with android 2.3(established by the client), but are changing the phones to 4.4 and use the sd card to store and then display as product…
-
5
votes1
answer295
viewsRetrieve the last saved photo and insert it into a View image every time Activity starts
I’m doing a job and I created a page that simulates a profile, so when a user is logged in, they can log on to that page and take a photo to be saved there. So, as soon as the photo is taken the…
-
5
votes1
answer1046
viewsHow to take data from a list only when there are two equal codes
Currently I can only take different data from two lists, for example: Lista X Código 1 Código 2 Lista z: Código 1 Código 3 I can only get the code 2 and 3. Now arose the need to take the same data,…
-
5
votes1
answer19133
viewsHow to create a custom Exception/Exception in Java
Java, brings with it several ready-made Exceptions, Illegalargumentexception, Illegalstateexception, Runtimeexception, among others. Creating a Custom Java Exception? I have the following method -…
-
5
votes1
answer1813
viewsHow to read whole numbers with Scanner and handle invalid entries
I have the following program, where I need to read a whole, print it out for the System.out However in my code, I want that when the program receives an invalid value as a String, I report the error…
-
5
votes1
answer550
viewsCan one override in builders?
Is it possible to override in builders? For example: @Override public class main (String arg[]){}
-
5
votes1
answer502
viewsConvert svg to png java
I am trying to perform an SGV image conversion to PNG, but am having some problems. My code: String svg_URI_input = Paths.get("/home/ivan/Documentos/imagem/Svg2.svg").toUri().toURL().toString();…
-
5
votes3
answers534
viewsReduce jar size in Maven Design
I’m generating a jar from a Maven project and the size is absurdly high. What measures can I take to reduce the size of this jar?
-
5
votes1
answer281
viewsText gradient android
It is possible to create a gradient in the text (and not in the background) of a textView using only XML? I know using Shader it is possible to do with code(here) It is possible to do this using…
-
5
votes1
answer182
viewsJsonexception being launched in Twitter search - Java
I have an algorithm that does a search of old tweets on Twitter. The application worked normally for a few days, but out of nowhere it started to throw an exception. Code: public static…
-
5
votes2
answers2674
viewsGenerate PDF with Jasper and download without storing it
I’m generating a PDF with Jasper, I’ll show you how it’s being done. I’m saving it on disk, storing the path in the bank and then downloading it. I would like to know how to make so that the moment…
-
5
votes2
answers305
viewsWhy is this Resultset returning null?
If I run a query in the database returns result, however, when running java code, assigning the result to a Resultset, the same appears to be empty. You can help me? PreparedStatement ps =…
-
5
votes3
answers11756
viewsChange format of a date from yyyy-MM-dd to dd-mm-yyyy
I have a dataTable where I display some data but the date is coming in format yyyy-mm-dd how do I change the format of this date so that I can display it correctly in my dataTable? And where do I do…
-
5
votes2
answers138
viewsIs hibernate considered white box or black box?
From what I understand the frameworks, Black box are known for their ease of use as it is not necessary to understand what is happening inside of it to use, and the white box otherwise, a knowledge…
-
5
votes1
answer711
viewsConvert String Ex. 1.520.30 to Bigdecimal using Spring MVC @Initbinder
I have a canvas on which I work with the monetary value masks of jQuery Mask, when the user performs the Submit of form the value returned to my controller is Ex:. 1.340,34. The attribute in my Bean…
-
5
votes1
answer666
viewsSend xmlns:xsi and xmlns:xsd namespace in the webservice Soap response
I have a webservice developed in java working perfectly, only that I need to send the namespace xmlns:xsi and xmlns:xsd as shown in the example below: <soap:Envelope…
-
5
votes4
answers602
viewsHow can I replace "String.isEmpty()" in Java?
I got the following: data = new Json().execute(URL).get(); System.out.println(data); if (!data.isEmpty()) { //erro neste data.isEmpty I have a mistake: has an error: Call requires API level 9…
-
5
votes1
answer2234
viewsTo limit and display the number of characters in a Jtextarea
I have a supplier registration window, and I’d like to insert a jTextArea so that the user has the option to enter some observation about the supplier. The idea is that, limit the amount of…
-
5
votes1
answer446
viewsMonitoring Mysql database c/ Java application
I have a Java desktop c/DB Mysql application running in 100 company branches for more than 6 years. Today at headquarters we need some information from the branch database. I am developing a web…
-
5
votes2
answers177
viewsWhat is the name of the concept employed in this code?
If I create for example two classes and place the class Funcionario with a variable Empregado in class Empresa, what this means and what it serves? class Funcionario { String nome; String cpf; }…
-
5
votes1
answer372
viewsData modeling via JPA and Hibernate
I’m doing a project with JPA regarding a quotation system and I’m having doubts on how to build the relationship between classes, and would like (if possible) some opinions. My project is a quote…
-
5
votes1
answer1579
viewsProblem with log4j configuration
How do I configure the properties of log4j? In my application, I am receiving the following message: log4j:WARN No appenders could be found for logger (org.docx4j.jaxb.Context). log4j:WARN Please…
-
5
votes1
answer211
viewsHow can I always keep my app in full screen without being minimized?
I am developing an application in Java that should stay in full screen and can not be minimized or give space to another application or even the OS, in a way blocking everything and leaving only it…
javaasked 8 years, 3 months ago Thiago Vanilson Florencio 51 -
5
votes2
answers1415
viewsAdjust Barcode Size Barbecue
I’m generating a barcode using the BBQ, but where I print the code is reduced or is the paper has dimensions 8 cm wide and the information I have to generate the barcode has 44 digits. I’ve tried…
-
5
votes2
answers5579
viewsHow to take only the number after the comma
When I do the 162/11 calculation, the result obtained is 14,72727272727273. But when I use the code System.out.printf("%.1f", teste);, the number is displayed 14,8. I’d like a way to keep just the 8…
javaasked 8 years, 3 months ago Lucas Caresia 2,663 -
5
votes1
answer353
viewsHow to deserialize a list with items of type { "key": "value" }?
I need to deserialize a JSON, but I can’t map the enumerated object. Follows the JSON: { "list": [ { "1": "Bola" }, { "2": "Quadrado" }, { "3": "Retangulo" } ], "code": 0, "success": true } My…