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
-
3
votes2
answers667
viewsHow to implement Swipe To Refresh on Webview?
I want to implement Swipe To Refresh on my Webview, is that possible? I know you have Pull To Refresh but I’m not able to download add-ons (dependencies) at the moment. I did a lot of research on…
-
3
votes1
answer1613
viewsFind String in Arraylist
ArrayList<String> posicoes = new ArrayList<String>(); posicoes.add("Ricardo;01051509912;gmail"); posicoes.add("Renato;123456789123;hotmail"); posicoes.add("Rodrigo;09873923121;yahoo"); I…
-
3
votes2
answers71
viewsSocket- does not receive the message in full
I have these codes: I’m still doing tests... Client system: private void btComunicarActionPerformed(java.awt.event.ActionEvent evt) { List<PessoaMOD> pessoas = new…
javaasked 8 years, 9 months ago Rodrigo Lima 315 -
3
votes1
answer907
viewsHow to list the name of the files that are in the directory?
The output of the following method is: C: Users Desktop User files filename.jpg How can I get just the filename.jpg in String format? I tried to use FileUtils but as a way out I got this: ����.…
-
3
votes1
answer403
viewsHow to use Java 8 Stream in an Object[] list
Imagine the following scenario: A list of Object[]. Something like that: List<Object[]> lista = new ArrayList<>(); Object[] dados = new Object[3]; dados[0] = 1; dados[1] = 20; dados[1] =…
-
3
votes1
answer250
viewsPartial update of object / Do not update null values with JPA
I’m using JPA for a webservice, and I’m using the Merge to update, but it updates all values of my object, there is some way to perform a partial update of it ? Example, only change values that are…
-
3
votes2
answers46
viewsError declaring Jtextfield vector in class
Well, I’d like to store all my JTextField in an array, however, when I define the array, I get the following error: llegal forward reference. Follow the code where I define the array. private…
-
3
votes4
answers11902
viewsHow to validate a standard EAN 13 barcode?
I would like to know how to validate a standard EAN 13 barcode like this 9788576356127, this code has 13 digits and the criteria for validation are: Perform the check digit calculation; Check if the…
-
3
votes2
answers818
viewsHow to count the number of occurrences of a String in a Jsonarray?
I’m trying to show the occurrence of the strings of "specialty" that are in my JSON, however, when I try to show the count of each "specialty" I cannot succeed. JSON [ { "id": "20", "medico":…
-
3
votes1
answer69
viewsNullpointexception when inserting element in list
In the code below is coming out a Nullpointexception, I tried to fix without changing completely the code but it did not work, someone has a simple solution? I’m looking to add a product to the list…
-
3
votes1
answer403
viewsHow to make a grid with squares?
I would like to do something like this one, a grid based on an array (and that based on the value of the matrix, set a color to the corresponding cell), and I can manipulate it with the mouse.…
-
3
votes4
answers543
viewsVariables operating in more than one method
I tried to make a simple console calculator, only I wanted to create several methods to make it well organized. The problem is that in the method of storing the variables, it stores, but when it…
-
3
votes1
answer355
viewsImport java classes to a project automatically?
I wonder if there is any way to automatically import java classes from a given local directory for my current project. For example: Let’s say that when I press a "Import" button in my application,…
-
3
votes1
answer1404
viewsHow to convert a byte[] from an image to a jpeg image to load into html?
In the html(jsp) of registration I have a field that the user registers his photo with the tag img with the following result. <img…
-
3
votes1
answer127
viewsBall movement in Volleyball game is too fast
For some time I’ve been developing a game of Volleyball in Java with Slick2d, but I’m having a very boring problem with the ball’s movement: I can’t get the ball to perform a parabola move (draw…
-
3
votes0
answers100
viewsHow to request permission to access sdcard on Android 6+?
I have an app that accesses sdcard, everything was working perfectly, but I noticed that Android 6 has a permissions system where the user has to accept the permission not when the application is…
-
3
votes3
answers550
viewsPrint the Thread ID
I have the following code and cannot print the Thread ID, only the size. How do I print the thread array ID? public class MultiplicacaoMatrizesThread { // Matriz A public static int a[][] = { { 5, 4…
-
3
votes2
answers679
viewsUse of instanceof
Create an abstract class Conta, and two other concrete classes ContaF and ContaJ inherited from the main class. Create another class with a method that receives a list of contaF and ContaJ and…
-
3
votes1
answer92
viewsProduct displayed is the smallest within the group (Criteria)
I have a function in the system that I am developing that returns a list of lots in which the batch quantity is greater than zero, searching for the product name (foreign key). Up to this point I…
-
3
votes2
answers1064
viewsJava constructor with matrix
I am learning about constructors in java but I stopped in college exercise that seemed simple, the proposal is to create a constructor class with a matrix, and call it in another class to assign the…
-
3
votes1
answer162
viewsThread of a "flashing" dot
Hello, I made a program that moves a ball with the arrow keys on the keyboard only that keeps blinking the screen when it moves. I’ve seen other programs in this kind of mine that don’t keep…
-
3
votes3
answers531
viewsString.equals and Nullpointerexception method
Although the doubt is very basic, I would like to understand why the equals in this case: String texto = null; System.out.println("teste".equals(texto)); Returns false normally (example in ideone),…
-
3
votes1
answer283
viewsWhen and why to use a parameterized constructor?
I am very confused. I wonder if it is better to use the default and setters to assign a value to the attribute, or if it is better to assign the values to the attributes via the parameterized…
-
3
votes1
answer896
viewsHow to change the name in the top bar dynamically when a Fragment is selected?
I want the name in the top bar to change according to the Fragment that is selected, for example, I chose the screen to list customers, so in the bar would appear "List Customers", but I’m not…
-
3
votes1
answer573
viewsProblem row with priority
Someone gives me a light of what to do to solve this problem, I have no idea how to start Write a program that simulates the distribution of service passwords to a group of people. Each person can…
-
3
votes1
answer936
viewsWhen to use Collections.emptyList()?
I thought I’d use List<Object> lista = Collections.emptyList(); to initialize a list. But when I try to do lista.add(element) I get a UnsupportedOperationException. After researching a little,…
-
3
votes1
answer524
viewsJava Vector Table Testing
I’m having trouble solving the next code table test, someone could show me the output and how to do it? public class Principal { public static void main(String args[]) { int array[] = {1, 2, 3, 4,…
-
3
votes1
answer140
viewsHow to escape all metacharacters using Pattern.Compile(.)?
Filing cabinet: ftp://paginaqualquer.html https://othersine.net/ http://mydeletina.php?id= My code: public static void main(String[] args){ //Supondo que o readLine() esteja no loop != null String…
-
3
votes1
answer2066
viewsHow to format field for RG with issuing organ?
I have the following java class: public class TesteRG { public static void main(String[] args) { String RG = "24.77.195 ssp/pb"; Pattern pattern =…
-
3
votes1
answer498
viewsPass the execution of a particular method to Swingworker as argument
I have a small application on swing, where I would like to display progress when certain actions are executed As an example, I have the listener below that is run when a JComboBox is changed. It…
-
3
votes1
answer743
viewsProblems with swing calculator operations
I need to make a calculator that works like the windows. I’m having trouble at the moment the user can change the type of operation he wants to perform. For example, if he typed 10+ and wants to…
-
3
votes1
answer336
viewsData sharing between android apps
I created an application that works as a calendar, where it is possible to register contacts with some more fields with respect to the schedules that comes preinstalled on the device. My question…
-
3
votes2
answers2074
viewsAdd line in Jtable at the click of the button
I’m starting in creating interface in Java, an example I’m trying to do is to have a form with textField nome and email, and by clicking on the Enviar the data of those textField goes to my JTable,…
-
3
votes2
answers707
viewsReturns database data in a Jtextfield
I have a question regarding listing the data I recorded in a database for a JTextField. I created a screen, with the field for the user to enter the registration ID in the database and a FILTER…
-
3
votes0
answers92
viewsIntercept SQL s on a custom JDBC
You can create a custom implementation based on JDBC to intercept all sql s executed in the application? I did not find anything very concrete about this in Google, I made a simple test just…
-
3
votes2
answers207
viewsUF field that accepts only 2 uppercase letters
I am trying to create a specific field for UF, in which only 2 capital letters will be allowed. I tried to use regular expression, but I couldn’t. Could someone give me a helping hand? public class…
-
3
votes1
answer516
viewsIs it possible to load classes dynamically and use them as a type?
I’m trying to make a code that loads classes dynamically and can use them to create instances and be used for cast. I can create an instance in the newly loaded class using the method…
-
3
votes1
answer755
viewsHow to convert java.util.Date to java.sql.Date keeping up hours, minutes and seconds?
I am doing a program in Java. In it I get a date of type java.util.Date, but I need it in java.sql.Date so that I can enter into the database. But on that date, I have hour, minute and second and I…
-
3
votes1
answer190
viewsDivision always resulting in zero
The Alpha result is only returning 0. Why? package javaapplication4; public class MediaMovelSuavizaçãoExp { public double CalculoPrevisao(double[] valores){ double[] values = new…
-
3
votes1
answer41
viewsProtect memory address
I’m developing a simple game. I want to protect the memory address where the player’s score is located so that only a specific process can access it, thus preventing the user from altering or…
-
3
votes1
answer217
viewsHow to remove Hover from menu items and buttons?
I think my question is very objective: how to remove the "Hover effect of menu items and buttons? Here is a screenshot of the Hover effect I intend to remove (button and menu items):…
-
3
votes1
answer270
viewsHow to capture the closing event in a Stage?
I’m looking for an event like "windows close" Swing.
-
3
votes1
answer160
viewsFramework to read json google maps api
I was wondering if there is a framework to read the data that comes in the json of google maps Directions? type, take the data and put in variables that I can take and use in the rest of the…
-
3
votes1
answer238
viewsHow to turn this query into a JPQL?
I have the following query in the postgres database: select * from trabalha_projeto tp inner join Empregado e on e.matricula = tp.empregado how it turns it into a JPQL query? I’m having a hard time…
-
3
votes1
answer56
viewsHow to create a non-circular geofence area?
From what I saw, the geofence creates a circular area from the measurement of the radius, in case it creates a circular area, but it is possible to create a non circular area? For example a square…
-
3
votes1
answer339
viewsShow data in a Datatable + JSF + Primefaces + CDI + Managedbean
Talk to me, people! I’m having a problem to popular a Datatable, I’m using Jsf, CDI. I believe that the name of teacher is coming normal because he is an object and the pupil is a List, But I don’t…
-
3
votes1
answer572
viewsConvert String to Calendar
I’m trying to make a conversion of String for Calendar but without success. My String is in dd/MM/yyyy format. I need to convert to yyyy-MM-dd And set on an object of type Calendar. void…
-
3
votes1
answer300
viewsCan I place two conditions/increments within the same loop?
I want to basically do this for (j = parametro, int k=0; j < parametro + 3, k<3; j++, k++) { previsoes[i] += valores[j] * pesos[k] ; }
-
3
votes2
answers172
viewsWhat’s wrong with multi-thread implementation?
The implementation below is merely a test class to test competition in Java. Multiple Threads are created that execute a method that adds up, then a return is displayed showing the sum result.…
-
3
votes0
answers182
viewsQuartz cronSchedule for running with an interval greater than one hour
I’m looking to do a cronSchedule of Quartz like this cronSchedule("0 0/5 * 1/1 * ? *") but it’s around every 5 minutes example 7:05, 7:10, 7:15, ... and so on What I need is this 7:05, 8:10, 9:15,…