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
votes1
answer98
viewsHow to execute requests in order?
I make 3 requests in a row, but they are fired in processing order, not synchronously, how can I resolve this? ... //botão pressionado // primeira requisição ivUpload.setOnClickListener(new…
-
3
votes1
answer998
viewsException class creation and implementation
I am having problems implementing an Exception class. The explanation of the program is: Vector strings must be initialized with "", not null. The vector capacity shall be capable of being changed…
-
3
votes1
answer487
viewsFragment is not overriding the marked layout
I’m working on a college project and I’m having a hard time replacing a given layout by a fragment. What is happening is that, the fragment is not replacing the layout of Activity but yes, mixing…
-
3
votes1
answer300
viewsObject is not updated
In my flow it’s like this: I already have an object stored in the database. When loading my page, these objects are searched in the database, treated to be displayed. Objects arrive in a List…
-
3
votes1
answer533
viewsHow to store data from Arduino in a Java string?
I need to store data from Arduino in the Java via serial communication only the values sometimes not filled in completely. I am using the library rxtx. //trecho do código para leitura int available…
-
3
votes1
answer77
viewsJAVA and Javascript
Imagine that we are receiving a JSON via REST, so for those who use spring or jersey, usually use the Jackson that deserializes the json string for java object automatically, that at first I was…
-
3
votes1
answer66
viewsWhat’s the difference if I instantiate a class within the method or if I instantiate just once?
Instance of a class each time I call the method: public String formatar(int valorFormatar){ DecimalFormat df = new DecimalFormat("###,###,###"); return df.format(valorFormatar); } Now an example of…
-
3
votes0
answers301
viewsHow the installment of the plot works with Pagseguro
I am implemented the payment part with credit card however when I will put the installments it returns me the following error: HTTP 400 - BAD_REQUEST [THE REQUEST CANNOT BE FULFILLED DUE TO BAD…
javaasked 7 years, 6 months ago Fernando josé 437 -
3
votes2
answers213
viewsJpanel width exceeding the dimension defined in getPreferredSize()
I’m trying to create a little game Breakout, I’ve done a lot of logic, only I discovered an uncomfortable problem related to the size of the panel of the "scene" of the game. Follow my class Board,…
-
3
votes1
answer914
viewsCircular dependency on Rest API with Spring Boot
I’m venturing into developing a Rest API using Spring Boot, JPA with Hibernate and Maven to manage the repositories. In my modeling I have a class Club: @Entity @Table( name = "CLUB") public class…
-
3
votes1
answer296
viewsProblem reading file line by line in Java
Hello, I’m making a java program to convert csv files to Bib. As the csv file may be 200kb or 2G I decided to read line by line so I wouldn’t have memory problems. I did the code as follows: try {…
-
3
votes1
answer1490
viewsHow to print a list in Java?
Guys I am studying the POO discipline in Java, I the teacher spent a content there that did not give time to write the code. Then I’ve got one hell of a question! I have 3 classes in java. Salaaula,…
javaasked 7 years, 5 months ago Sandson Costa 509 -
3
votes2
answers2148
viewsCORS JAVA (ERROR)
I’m trying to connect to an API that was made in Java, but always error when trying to connect (I want to feed a mobile application, made in JS/Cordova). When connecting (via Browser) I can, the API…
-
3
votes2
answers3800
viewsLong or Date in JSON
Applications, one server and several customers, POST and GET to the server exchange objects JSON. One of the variables that goes along with the JSON is the datahora atual, see different Strings to…
-
3
votes0
answers158
viewsMaxlength in Textfield
I have a Textfield in javafx, but I can’t find the Maxlength property. In C# and QT5, I have already made some applications, and it is very simple to find this property. I have found some answers,…
-
3
votes0
answers57
viewsHow can I save images through url before displaying them using Fresco?
I loop the list with the images as follows: for( Produto p : listProd){ String error = ""; cont++; try{ // salvando dados no db produtoRepository.insertProduto(p); // salvar imagem p.getImg();…
-
3
votes1
answer84
viewsNavigation Properties - Domain-Driven Design
Hello, I am studying DDD and came across the following question: There is the Aggregate (Aggregate), a set of related objects that have an Aggregation Root (Aggregate Root). So far so good, I…
-
3
votes2
answers182
viewsHow to create a Layout bitmap keeping the dimensions equal regardless of the screen density?
I have a layout file and I’m passing it to a bitmap which I then send to a printer bluetooth in bytes. According to the resolution of the cell phone, it changes the sizes of the sources of textviews…
-
3
votes2
answers185
viewsRelation between bean and view
I have three views that show the same table with a sequence of leds and information, I have a class service that makes the business logic to know which led and which color to show, in my bean…
-
3
votes1
answer509
viewsUsing Criteria for sorting
In the system I am developing I am trying to use the criteria to be able to execute a query that I am not able to make work by jpql, so I tried to execute according to the material I had getting to…
-
3
votes1
answer125
viewsWhite space JSTL
I have a very annoying problem, when my jsp is mounted I have a jstl foreach that leaves my final code absurdly giant, worse than I realized it’s just blank space. Follows the code : <c:forEach…
-
3
votes1
answer199
viewsHow to call youtube API with multiple parameters?
I’m trying to get the data from various videos, but the Youtube API is separate for videos and playlist, then I used the API of playlist to obtain the VideoID of each video in a given playlist, but…
-
3
votes1
answer265
viewsButtons (Action) in the notification. How to know which one was clicked?
The purpose of the notification is to show a question to the user, and the user has two response options, "YES" or "NO". The problem is knowing which button the user pressed. Another thing that I…
-
3
votes1
answer762
viewsWhy use the Observablelist?
I have a theoretical doubt. I was studying Javafx and do not know what the function of Observablelist in this case: public void start(Stage stage) { //Creating a Text object Text text = new Text();…
-
3
votes1
answer530
viewsImage capture for Base64
Man app take an image from the gallery or take a photo, how to grab this image and convert to Base64? private void onCaptureImageResult(Intent data) { Bitmap thumbnail = (Bitmap)…
-
3
votes1
answer295
viewsStackoverflow in Quick Sort
I’m having a problem here at this meeting. These are functions for an array of objects using the Quick Sort algorithm, and I’m getting the Stackoverflow error, and I can’t identify the source.…
-
3
votes1
answer75
viewsHow to load changes made in native java classes?
Hello, I am trying to run a jar file, replacing some original java interfaces for database connection, changing the setBoolean method to receive an object as parameter. Original: void setBoolean(int…
-
3
votes1
answer142
viewsLambda expressions in nested classes with multiple methods
I was reading about Ambdas and out of curiosity, I wanted to know why it is not allowed to use when the class/ interface has more than one method, which ends up forcing us to do things like below:…
-
3
votes3
answers150
viewsProblems using string for resources
I’m creating an app quiz, the link is https://github.com/luisbalmant/QuickQuiz-Science. I’m trying to use the getString(R.string.nome) to migrate the java class strings and then be able to use 2…
-
3
votes1
answer111
viewsREGEX - How to capture blocks of CASE WHEN ... END
Good morning, you guys. I’m trying to make a regex to capture blocks of CASE WHEN ... END. So that string: iduser + CaSe WhEn ("end") = 0 THEN 'CASE WHEN' ELSE ' END ' END + sum(iduser ) + CASE WHEN…
-
3
votes1
answer238
viewsIgnore attribute in POST using Retrofit
I would like to know how to ignore a model attribute in a request POST with Retrofit. In requests GET I want to bring all attributes, but in requests POST I need to send the object without the id…
-
3
votes1
answer784
viewsHow to use Bufferedinputstream correctly?
I am creating an application in which I need to read from a video file and transmit packets of data that can be read again in memory. I am using the Ogg video format, because it is open source and…
javaasked 7 years, 3 months ago Rodrigo Brito 43 -
3
votes1
answer991
viewsCalculate age by taking a date of type Date
I’d like to calculate the age by taking the date of birth from the database, through the pojo. I was looking at how to do a date calculation, looking at this question: Calculate age per day, month…
-
3
votes2
answers1303
viewsHow to transform an Object into XML in the specified format?
I would like to generate the XML for a request that I will make on Java from an object. The XML that I want to generate is the following: <?xml version="1.0" encoding="utf-8" standalone="yes"…
-
3
votes2
answers260
viewsRetrieve json object
I have the following object: { codigo : "1", nome : "Carlos" } Java class (POJO) public class usuario{ @SerializedName("codigo") private int codigo; @SerializedName("nome") private String nome; /*…
-
3
votes1
answer226
viewsDownload data in JSON
[ { "ID": 1, "ano": 5 } ] I don’t know how to get in JSON the value of each of the fields, in this case "1" and "5", as shown above. In obtaining the data in JSON I tried to follow some tips that I…
-
3
votes1
answer541
viewsQuestions with mask in Jformattedtextfield
Working with JFormattedTextField, I had two problems for which I found nothing that helps me to solve. The example in this case would be a JFormattedTextField for CPF. First problem: the mask. When…
-
3
votes1
answer454
viewsJava program does not find the Jasper report path
I made a small program in java to generate budget reports, I used for both Jasper Ireport, made, tested, generated the budgets all running on my computer. When I installed it on a friend’s computer…
-
3
votes1
answer141
viewsIs this some kind of "Anonymous Implementation"?
Since there are no instances of interfaces, what the code below does with the interface Comparator? Collections.sort(obj, new Comparator<T>() { @Override public int compare(T t1, T t2) {…
javaasked 7 years, 3 months ago igventurelli 4,441 -
3
votes2
answers1981
viewsHow to subtract hours in java?
I am trying to days make the difference of hours in my application. The case is as follows: Based on the Current time and current minute, I want to compare another time I have in a string and I need…
-
3
votes1
answer622
viewsHssfworkbook - How to copy one spreadsheet to another?
I have a spreadsheet of excel I need to copy some data into another spreadsheet. This old spreadsheet is like a "base", I need to copy only the header and caption part (with the cell style, in…
-
3
votes1
answer570
viewsServlet Container (Tomcat) or Application Server?
I am currently developing a project that uses JSF, JPA, CDI and EJB. I read in several places where they said that Tomcat (Servlet Container) does not have support for these technologies, but…
-
3
votes1
answer659
viewsSave status of a Checkbox
I need to save the status of my Checkbox, they’re inside a Spinner, and every time I open Spinner he cleans the Checkbox. Admlistagem.java final String[] select_qualification = { "Todos", "1", "2",…
-
3
votes1
answer866
viewsClose Dialog after 10 seconds open
I would like the dialog close after 10 seconds. I can only do it by clicking the button. Follows the code. AlertDialog.Builder alert = new AlertDialog.Builder(this); WebView wv = new WebView (this);…
-
3
votes2
answers244
views -
3
votes2
answers2465
views2 decimal places using double
I am learning to program, I am making an application with 3 edittext (where I insert the numbers I want to calculate) and a textview to present the result. I would like to know how to calculate 2…
-
3
votes1
answer790
viewsCheck whether the field is null in java and mysql
How do I check if a database field is filled or null? Do you have a Resultset method that does this check? In this case it is a date field. PreparedStatement ps = connection.prepareStatement("SELECT…
-
3
votes1
answer420
viewsTime complexity of recursive palindromic algorithm
I need to analyze the time consumption of my algorithm for a size vector n = f - i + 1, through a recursion, to then define a closed formula. public class ehpalindromo { public static boolean…
-
3
votes3
answers722
viewsFormat String to "00:00:00"
I need this string to come out in 00:00:00 format currently it comes out: 5:4:1 for example, what I did was to do several ifs, but it is not efficient, and also it does not format when the 3 are…
-
3
votes2
answers772
views...on a null Object Reference
Hello, I am at a time with this problem and I can not find solution, I have looked thousands of topics and I can not understand yet why this error appears to me. Error…