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
-
2
votes1
answer155
viewsData is not displayed in the table by Abstracttablemodel
I am developing a ticket request system, but for having to add a JXDataPicker in the table, I had to implement the AbstractTableModel. The model apparently agrees with the documentation, I can…
-
2
votes1
answer807
viewsManipulating a JSON with the GSON library
This is the json: { "professor": [ { "latitude": -23.1843473, "longitude": -45.8840718, "title": "Microcamp", "endereco": "rua vilaça 2010" }, { "latitude": -23.1843473, "longitude": -45.8840718,…
-
2
votes1
answer54
viewsAndroid/Firebase - Nullpointerexception when setting Query object
Hello, I have a problem while reading the data in Firebase. I use Android Studio 3.0 and Java. I can connect to the database, get the instance, the logged in user, but I’m not able to read the…
-
2
votes0
answers88
viewsHow to calculate interest and discount on a line?
On my button I declared so: numero_de_parcelas = Integer.parseInt(txtNumeroParcelas.getText()); juros = Float.parseFloat(txtJuros.getText()); desconto = Float.parseFloat(txtDesconto.getText());…
javaasked 7 years ago Victorprvt 165 -
2
votes1
answer102
viewsArrows do not move in text field with regex
I have the following code with a regular expression inside a method Keyreleased, which allows only some characters to be typed by the user in a text field: String text = input.getText(); text =…
-
2
votes0
answers595
viewsTraffic Light Problems (Readers and Writers)
I am trying to implement the problem of readers and writers in Java, and for this I am basing myself on the method used by Tanenbaum in the book Operating Systems. With only one writer thread and…
-
2
votes1
answer48
viewsError in Method Get on a Collection
I need to use XML in a university job and had problems with a method Get that I had to implement in a Collection. After a while I ended up taking a look at some sites to do this and found the…
-
2
votes1
answer95
viewsMergesort, problem of logic
Gentlemen, I’m having a problem with my Mergesort sorting algorithm, I feel the problem is in logic. Merge code: static void mergesort(int[] x,int inicio,int fim){ if(inicio<fim){ int meio;…
-
2
votes1
answer67
viewsCode in infinite loop
I developed the following código to take the content of a given web page: import java.util.logging.Logger; import java.util.regex.Matcher; import java.util.regex.Pattern; Logger logger=…
-
2
votes1
answer209
viewsHow to insert a value into the prompt box?
I need to access a web page, through the component WebView. 1- I can load the page. 2- I can intercept the button event. I can’t insert/ inject var name = prompt("Introduza o numero:"); Note: The…
-
2
votes1
answer1053
viewsAdding arrays (vectors) with methods
I have an exercise to do: create a method where the user enters the values of 2 vectors, then create a method to sum the values of the 2 vectors and finally a third method that shows the new vector…
-
2
votes2
answers135
viewsDoubt about access modifiers and polymorphism
I have a very beginner question about polymorphism/access modifiers in Java. I’d like to find out why a certain phenomenon occurs in my code. Below is an example of classes: Class Pai: public class…
-
2
votes1
answer1331
viewsHow to order a list in alphabetical order?
I own a List<ListaUsuarios> and I want to sort it alphabetically by name My code is like this User class: public class Usuario{ private String nome; private String empresa; private int idade;…
-
2
votes3
answers1406
viewsHandling JSON with JAVA
Through JAVA, I need to make a request via POST, where I will get a JSON with a token. The JSON return I get after sending the POST is this: { "Token": "e27bb0a7-e65b-4cc3-a82e-7a2a3c26a248",…
-
2
votes0
answers85
viewsHow can I add ships of size 2 or more
I have the game of naval battle done in java. It runs perfectly, the position of the ships is randomly drawn... But I wanted to make sure that there could be ships with more than 1 size. That is,…
javaasked 7 years ago Nelson Silva 21 -
2
votes1
answer29
viewsHow to insert a data in your respective Acitivity via Sqlite
Guys I’m making an app on android and inside it has a listiView fixed sent by a string array for example String[] servicos = {"Eletricista", "Pedreiro", "Pintor", "Encanador", "Arquiteto",…
-
2
votes1
answer85
viewsAndroid take data from Imagebutton to send in a post
I have a view type Fragment with a form, in this form I have an imagebutton in which I load images from the Android gallery when I save this form I need to take this image and post in Base64. public…
-
2
votes1
answer129
viewsData disappears while moving Recyclerview scroll with Firebase
Hello folks I am creating a chat with Firebase and listing with Recyclerview, to list the messages but I am with a problem is that when moving or scrolling Recyclerview some messages disappear,…
-
2
votes1
answer50
viewsProblems with Firebase Insertion
I am developing a native application on Android that uses maps, the insertion is normally happening through the code below. Local is a variable of type LatLng.…
-
2
votes1
answer143
viewsMethod does not return true Boolean even if it is positive
I am with a project account that makes a deposit, however I am not able to return a true even it finding the value in the database this my Class method counts public boolean depositoConta(double…
-
2
votes2
answers377
viewsTransform String into Array - Groovy
I own a String as follows: [["155","123RET"],["156","124RET"]] In other words, in it two subArrays that I need to add an item still in each one, my need is that in the end these arrays stay as…
-
2
votes1
answer65
viewsHow to save Strings from a file read?
Guys I’m reading a.txt file and would like to save all the strings as I could save it all ? Below follows my writing code I am using , in case I would like to guard the String line . public static…
-
2
votes1
answer111
views@Preupdate com @Transient - Eclipselink
I need a @Preupdate method to be called when a @Transient attribute is modified. This @Transient will always be modified, so yes, @Preupdate would have to be called every time. Since it will always…
-
2
votes2
answers7879
viewsSelect Join with JPQL
Talk guys! I’m busting my chops here on my TCC and I need your help. I know the trouble I’m in must be very silly, but I don’t have much knowledge. I searched everywhere, JPQL documentation and…
-
2
votes1
answer48
viewsOnetoone returning wrong value
Guys, help me please, I’ve got a problem here and I’ve been racking my brain trying to figure this out for hours. I use Spring in the project and have the following relationship in one of my models:…
-
2
votes2
answers393
viewsError storing data from a Select with Java
Good morning guys. I wonder if you have the possibility to store in a variable the value of a search (select). In case I want to store one id another table using a select, however after doing the…
-
2
votes1
answer155
viewsHow to check the size of a PFA-type array?
How do I check whether the array PFA (Partially-full array) is full and new elements cannot be added? If it is full, it should return true. boolean estaCheio(int[] data, int size){ ??? } I have 5…
-
2
votes3
answers3811
viewsUnparseable date: "2017-10-30T02:00:00.000Z"
I am setting up a register where I pass a date and, when saving, is showing this error: java.text.ParseException: Unparseable date: "2017-10-30T02:00:00.000Z" at java.text.DateFormat.parse(Unknown…
-
2
votes4
answers168
views -
2
votes1
answer144
viewsjsonarray adding and overwriting
I’m creating a game and I’m in the monster part and I need a json file to save the monsters but when I create a new monster it writes on top of what already exists as I arrange to just add a new…
-
2
votes2
answers1166
viewsSearching an Arraylist in Java
I’m trying to do a search using the .contains(); of ArrayList, but I can’t return. It’s option 3 public class Fruteira { public static void main(String[] args) { Scanner input = new…
-
2
votes0
answers1249
viewsGet redirected link internally in android app
Aloha I’m developing an Android app to log in to the wifi network, but I found a barrier. In the application, when the user clicks on the "Log in" button, I need to internally access some address…
-
2
votes1
answer120
viewsRecyclerview scroll position with Firebase
I am listing data from Firebase in a RecyclerView, but when adding or removing data, the data is repeated in the list. I used the clear(); or lista.removeAll(lista); to clear before filling only the…
-
2
votes1
answer38
viewsHttpurlconnection Android + Msyql
The Code works perfectly more I need it without using Asynctask because I call several times in my code every time I finish running(onPostExecute) I call different methods or functions... I need…
-
2
votes2
answers1539
viewsc3p0 error - bad pool size config start 3 min 5. using 5 as start
Hey there, guys! Can anyone help me how to fix this error below? I tried a lot and nothing. Error: 12-Dec-2017 20:27:27.908 INFO [http-nio-8084-exec-6]…
-
2
votes0
answers196
viewsUnable to calculate MD5 hash in upload file using AWS Sdk in java
Guys, I’ve searched several forums and no solution solved my problem. When I upload the file to S3 using the Amazon API. The following exception shall be made. com.amazonaws.SdkClientException:…
-
2
votes1
answer584
viewsTest with junit
I developed a simple Bank system, now I want to know how I can use Junit only in the ways to withdraw and deposit. package CaixaEletronico; import java.util.Random; import java.util.Scanner; public…
-
2
votes2
answers519
viewsValidation in an ATM
The user starts by putting a name to the account and the initial balance, here already has a problem, I want it is not possible to enter negative values or broken numbers In the deposit option I…
-
2
votes2
answers174
viewsVector receiving a function that returns integers
Guys, I have some questions about vectors and functions. public class teste{ /*Função que retorna um vetor de inteiros com números aleatórios*/ public static int [] vetorFuncao(){ int…
-
2
votes1
answer90
viewsConvert Arraylist to Object[][]
How to convert an Arraylist to a 2D Object. My Current Code: ArrayList<String> a = null; a = new ArrayList<String>(); a.add("ABC"); a.add("DEF"); a.add("1"); a.add("1"); //Converter para…
-
2
votes1
answer593
views -
2
votes1
answer261
viewsText file is not displayed completely in Jtextarea
I put it up to show you the packages, so you can tell me if I’m making proper use of the MVC If I save in txt: [Maria;32] ; [Joao;44] e [Luna,12]` he just shows me Nome: Maria Idade 32 and Nome…
-
2
votes2
answers681
viewsError in String to Double conversion
Setting: public void metodoX(Double valor) { DecimalFormat df = new DecimalFormat("0.00"); String valorRound = df.format(valor); Double valorRound2 = Double.parseDouble(valorRound); ... } Error:…
-
2
votes2
answers1238
viewsread only first and last line file
I’m taking all the lines of my file. However I can’t get first and last to save in a variable. I have following code snippet to read file: ler = new Scanner("C:\\Users\\Douglas…
javaasked 6 years, 11 months ago Douglas William 49 -
2
votes1
answer156
viewsConvert java lambda predicates
I am trying to perform a model transformation using java lambda. Below follows a block of code that exemplifies what I want to do: public String translatePrimitivePredicate(){…
-
2
votes1
answer70
viewsChange of themes through Java
Hello! I have a java code where I would like to change the Androidmanifest themes according to the return of a certain function. Example: Having a boolean function that checks the internet…
-
2
votes2
answers963
viewsRun HTTP POST asynchronously in JAVA
I have a method that sends a POST to the server, how can I send multiple requests asynchronously? public void sendPost (Object content) { ObjectMapper mapper = new ObjectMapper();…
javaasked 6 years, 10 months ago Mateus Carvalho 1,494 -
2
votes0
answers67
viewsI can’t save photo in the bank
I am creating a web application that registers employees,and in this register there is an option to upload photo to link to profile, but when registering null arrives in the bank. Can someone help…
-
2
votes1
answer129
viewsApache POI - How to put Hyperlink in an image in Excel?
This is the method I use to put images in Excel: public void insertIcons(String URL, Sheet sheet, int colBegin, int colEnd, int rowBegin, int rowEnd) { try { InputStream iconInput = new…
-
2
votes0
answers128
viewsHow to differentiate sessions in browser guides?
In a web application implemented in Java using JSP and Servlets, if I store information in the user’s session, this information is shared from all tabs in the same browser. How to differentiate…