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
answers1129
viewsWhen can I use Static in class?
I know the use of methods static should be avoided, so I have a question and I do not know if it is right to implement a ArrayList as static, it is accessed by several classes and contains data from…
-
3
votes2
answers140
viewsInstantiate an object throughout the life cycle of the Java application
I have an application here in Java that uses the Amazon SDK to send images to a Bucket S3. To do this I use threads, basically it is modeled as follows: The class Main has a thread list and each…
-
3
votes3
answers54
viewsDate does not receive value more 30 days
I have a code that I want to check if the date is over 30 days with Jodatime, but putting in the console output the value is not assigned. I saw the following:…
-
3
votes0
answers658
viewsGET Okhttp Java Request
I’m using Postman, and when making a requisition GET, everything goes well and the JSON with the data.However, when I take the java code(below), this request and execute it, I am handed the…
-
3
votes1
answer74
viewsWhy does the Matcher class not return the number of groups correctly?
After the question "What is the difference in use between the Matcher() and find() methods?", I kept testing this class to understand its functioning, but I came across a strange behavior. When…
-
3
votes1
answer65
viewsLost date format
I need to assemble a condition to subtract a day from the date, for example I created a new column in the database and I need to fill it, the condition to fill it is the following, I’ll take the…
-
3
votes3
answers915
viewsRandom without repetition
Well, I have a question that’s been killing me for a long time, and I can’t fix it. PS: I’m a beginner on Android. I am developing an application of raffle, but I am not able to generate a Random…
-
3
votes1
answer31
viewsIs action confirmation widget possible?
I have to put a Alertdialog to confirm if the user really wants to perform certain action, it is simple to do this in an Activity or Fragment only I’m having problems to do this in the widget, I…
-
3
votes1
answer53
viewsHow do I create a showOptionDialog method that the default value is "no"?
I want my system’s confirmation messages to behave with the default value "no". I have achieved this by doing so: private void jButtonActionPerformed(java.awt.event.ActionEvent evt) { Object[]…
-
3
votes1
answer202
viewsManual configuration of Spring Data
I’m trying to use Springdata on a Jface/SWT project. Because the Crudrepository self implementation feature is something fantastic and very advantageous. For this, I include here in the classpath…
-
3
votes1
answer2462
viewsPut multiple classes in the same file
In my project I have the class main and created new Java class files with Netbeans to define the objects there. I can only use in main one of the classes, the others I can’t even call the methods.…
-
3
votes0
answers83
viewsInventory with Android
I’m trying to create an app for product control type an inventory, in case the user selects on RadioButton the product and then with scanner will read the equipment serial. The scanner is working,…
-
3
votes1
answer26
viewsI don’t understand an ordination resolution
The teacher asked for the next exercise: "Write a program that receives three scores (integer numbers); sort these scores using if instructions and write the three in ascending order on the screen."…
-
3
votes1
answer1534
viewsPass an object between Javafx (screens)
The idea of the system is to save some information in a txt file that will be consulted by a code in Lisp, a decision tree routine will be performed and return the result to be displayed in the Java…
-
3
votes1
answer266
viewsAlternative String.replace()
I got a flea behind my ear. I have a method that removes / changes some characters from the string, it is something like this : public static String replaceCharSet(String texto) { texto =…
-
3
votes1
answer2436
viewsWhat is the (real) usefulness of the javax.persistence.Transient annotation?
The annotation @Transient serves to inform JPA that that attribute is not mapped in the table and/or should not be persisted. In addition, after the entity that has attributes annotated with…
-
3
votes1
answer885
viewsHow to display the contents of a . txt file on the screen?
I’m using JFrame to try to display the contents of txt files in a window and then delete the entire file. However, when I put it to display, it erases the file no longer displays on the screen I…
-
3
votes0
answers112
viewsHow to create Microservices thinking about scalability?
Hello, I’m building a microservice that integrates data from a SOAP webservice. For this I am using a scheduler that once a day searches new data and writes in my base mongodb. Since the standard of…
-
3
votes2
answers460
viewsRecursive or loop method to popular or list an n-dimensional array
I’m trying to build a method capable of filling an n-dimensional matrix in all positions, for example: I have a 2-dimensional matrix, where this matrix is 2x2 with only 2 dimensions in a Cartesian…
-
3
votes1
answer535
viewsSave key with various values in Properties file
I have a file .properties where I carry the name of the tests that will be deleted from my application. This file needs to have the same name as the "variables" since they all mean the same thing…
-
3
votes1
answer6369
viewsHow to build a SELECT on Sqlite?
I am new in Android development, I am using Sqlite as a bank. I need to make a SELECT, and return the values of three columns of my table. Then I need to set the attributes of my object with the…
-
3
votes2
answers216
viewsUse of Google Admob
I am using google admob to place ads in my app, but I have some questions I can use the same ad block (id) for multiple Activity (each with a block)? How do I make the ad the first thing to load?…
-
3
votes1
answer286
viewsonclik event() Error opening camera
I’m developing an android app I have an event on the Button to open the camera: On Androimanifest.xml <!-- Permissão para acessar a área de memória externa --> <uses-permission…
-
3
votes2
answers433
viewsHow to indicate how many equal numbers there are between two vectors?
I’ve got this exercise here from college: Write a java program that takes two size vectors different and then indicates how many equal numbers there are between these two vectors. I’m not able to…
-
3
votes1
answer240
viewsWhat is the most performative way to convert int[] to int?
What is the most performatic way to convert the inverted positions of a array for int? For example, the following array should work in full 153 for the purpose of future calculation: int[] a = new…
-
3
votes1
answer225
viewsSave frames/ images of a video
Hello, I need to save pictures/frames from a video. The idea is to create a preview of the film before it starts. The problem is I’m not being able to implement the examples I found. First example…
-
3
votes1
answer121
viewsHow to make two Retrofit chain calls with Rxjava?
I make a call to recover some data and the second call - which should be made inside the first one - uses one of the fields of the previous call. val restApi = retrofit.create(RestAPI::class.java)…
-
3
votes1
answer82
viewsHow to improve this code
A few days ago I asked for help here in the OS to parse JSON in Java and I got what I wanted, however, I had to do a "gambiarra" by not knowing a better way. It’s working, but I’m sure the code can…
-
3
votes1
answer431
viewsWrite to txt file save, read and save to one in another txt file
I just started working at a company that programs the Mifire cards and I’m in the experimental phase. Meanwhile the engineer ordered me to do a job. First stage: I have to enter two numerical values…
-
3
votes1
answer68
viewsError executing class with parameter by main
I am trying to compile my code by cmd, passing the image parameter (name and format). But it returns me this error. java ImageSplit tileset.png Exception in thread "main"…
-
3
votes1
answer1161
viewsHow to save a PDF file to the database and make it available for download?
I am developing a web application using Playframework, and I need a file that will be a kind of guide (documentation) for users who will use my application to be able to download or view by the…
-
3
votes1
answer527
viewsHow to capture camera image from your phone and send it to the server via Rest using Volley?
I’m developing an application MOBILE that communicates with my web application, the application developed in Android Studio and the web on Playframework. I created a form on APK that already makes…
-
3
votes1
answer2372
viewsHow to add the eye to display the password in Android Studio?
I created a login form in my application and would like to put the eye button so that you can display the characters of the login field, as shown in the screenshot: I’ve done some research and tried…
-
3
votes1
answer17224
viewsPKIX path building failed: sun.security.Provider.certpath.Suncertpathbuilderexception: Unable to find Valid Certification path to requested target url
Hello, I’m trying to compile my project using the sbt, but causes an SSL error: Server access Error: sun.security.validator.ValidatorException: PKIX path building failed:…
-
3
votes3
answers430
viewsReturn method in Java
I don’t know anything about Java. I would like to know how to get the return value of the variable dv that is within the method Base10() and use it on main. Could someone help me? public class…
-
3
votes2
answers287
viewsHow to avoid Lazyexceptions?
My application faces numerous Lazyexceptions problems and what causes a "mess" in the server log. I understand that they occur because the connection to the database has already been closed and I am…
-
3
votes1
answer78
viewsWhy is Hibernate deleting before saveOrUpdate()?
I have a m:n relationship between Column and Element. The entity that owns the relationship is Column. but when I’m saving a map of Columns, the following scenario happens: 1) In the first…
-
3
votes2
answers1864
viewsJunit 5 - How to run a test method only if another test method passes?
It would be something like that: @Test void metodo1() { assertTrue(...); } @Test void metodo2() { //Deve ser executado após método1(), e SOMENTE SE metodo1() passou! assertTrue(...); } I need to do…
-
3
votes1
answer1007
viewsAndroid - What is the difference between getReadableDatabase() and getWritableDatabase()?
I was able to enter information in the database using the method getReadableDatabase(). In that case shouldn’t it be wrong? Shouldn’t it be the method getWritableDatabase()? private void savePet() {…
-
3
votes2
answers894
viewsHow to exchange/exchange the value of two variables
I’m having a hard time writing this exercise in the Java language, using the Eclipse IDE: Read two values for variables A and B, exchange the values so that variable A has the value of variable B…
-
3
votes2
answers204
viewsBetter structuring of object-oriented code
I came across a problem with code structuring and I needed some help. I made a diagram below with two different methods of structuring the same code (I couldn’t create the code yet) and wanted to…
-
3
votes3
answers214
viewsJava Mergesort sorting algorithm error
I was doing the Mergesort sorting algorithm in Java for study purposes and every time it runs it gives error. I’ve already revised the logic of the algorithm, already replacing the array of integers…
-
3
votes1
answer62
viewsHow to turn a number reading directly into a stream?
Recently I wrote a reply exploring a little more the API of stream of Java 8, but I must say I was disappointed with some details of my code. The idea was to read a sequence of numbers and then…
-
3
votes2
answers825
viewsLambda in Java 8 launching Exception
I have the following problem. I need to perform a user update process and your group, and to perform the change I perform the user search, validating if it exists and soon after, I look for the…
-
3
votes2
answers827
viewsProblem with component position and size
I’m doing a program using the wizard, the famous "click and drag". Most of the project I’m doing on my computer, and I use the command to maximize the screen on the frame, and I adjust the panels so…
-
3
votes1
answer349
viewsJWT token with spring, for user authentication
When trying to validate this method: Jws<Claims> parseClaimsJws = setSigningKey.parseClaimsJws(token);, it shows this exception on the screen JWT signature does not match locally computed…
-
3
votes1
answer83
viewsPossibility of application of design standard
After a login effective in the application I am building I return a boolean[] with all the accesses that the user has. // Armazena o controle de acesso do usuário LoginDAO logindao = new…
-
3
votes2
answers866
viewsCompare using String.Contains() disregarding accents and case
I know there’s already question, I even used the same title to call attention, but this one refers to C#, I’m having this problem in java, code: //historico e searchC são ArrayLists, no caso do case…
-
3
votes1
answer121
viewsMbean named conflict when climbing two Spring Boot applications in the same Tomcat
I have two applications in Spring Boot that use a common nomenclature for Beans. In case, man pool of connections to the database is managed by Hikaricp. Due to an infrastructure problem, I had to…
-
3
votes2
answers648
viewsIgnore scoring in a sequence of numbers using Regex with Java
I have the following input: Fatura Cliente: 1.7852964.34 CPF/CNPJ: 09022317000222 I need to take only the "Customer Invoice" numbers, ignoring scores, returning only 1785296434, for this I am using…