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
answer2094
viewsCreating product registration using arraylist
I would like to create a product registration program using the ArrayList. How I put a loop to read NOME, MODELO, TAMANHO and PREÇO and store this first loop at an array list location? What code I…
-
2
votes0
answers57
viewsHow to pass x seconds and perform the action itself
I have a question in Java. Basically, I wanted to get a fillrect to draw 0.5 in 0.5 seconds, more or less this way: if(passedTime >= 0 && passedTime < 500) { g.fillRect(0, 45, 64, 64);…
javaasked 5 years, 4 months ago Rodrigo Matela 21 -
2
votes1
answer106
viewsProblems with the JDBC connection
Good morning, my dear. I’m having trouble with jdbc. The connection to the bank is made but, does not bring anything with select. The eclipse console reported me some problems, such as: The…
-
2
votes1
answer175
viewsJWT IN JAVA (SPRING BOOT)?
I’m doing a project, where I have a login. Front-end use in Reactjs, and backend in Java. But I don’t know how to make a java JWT token so that the front end can be successfully logged in. I read…
-
2
votes1
answer560
viewsRead API return on a Jsonobject in case of errors in the URL
I am trying to consume a weather forecast API (https://openweathermap.org/current) in Java but I have a question regarding the return of JSONObject. I’m using the following code to generate the…
-
2
votes0
answers130
viewsWhy does an integer not format correctly (Kotlin/Java)?
I use the Android Studio 3.4.2. I ran a test code that generates a very strange format. This excerpt was placed right after the beginning of the onCreate. And it’s a pure integer! fmtFloat =…
-
2
votes1
answer339
viewsPermutation between arrays in Java
I am trying to create a code that generates a data matrix. This matrix consists of all possibilities between certain arrays. My arrays are: [Corretor, Clientes] [Para Voce, Para sua Familia, Para…
-
2
votes1
answer126
viewsIndexoutofboundsexception No Get(0) do Crawler jsoup
I would like to get the names of the companies that appear in a search like "Farmacias em Santo Andre" on Google Maps. Erro: Exception in thread "main" java.lang.IndexOutOfBoundsException: Index 0…
-
2
votes3
answers1652
viewsConvert a JSON to a Java list
I’m having trouble turning a JSON into a Java list, I tried with GSON and Jackson, but I couldn’t succeed with either. My JSON is formatted like this: [[["00000000000","00000","Fulano de Souza",""],…
-
2
votes1
answer201
viewsPass parameter through AJAX
I am making a page where the user click the button will display some database information, only it is passing only a part, I do not have much experience with javascript, my code is <?php…
-
2
votes1
answer209
viewsError while creating tables simultaneously in sqlite database
I’m developing a mobile application that saves data from a form in the local database, using the sqlite. Only every time the database is reset or changed its version it returns me an error that…
-
2
votes0
answers47
viewsDesign using SPRING MVC does not perform CRUD on the bank correctly
I have a Controller with some implemented methods that save, update and remove my object pr of the kind professorRepository on the bench. I am using the Spring boot for this project, then the CRUD…
-
2
votes4
answers428
viewsHow to validate data passed to a constructor?
Is there a way to handle possible errors or validations by instantiating a class using the constructor? For example, this is my constructor: public boolean ContaFisica(int agenciaConta, int…
-
2
votes1
answer114
viewsKnow the total file size to download
I have the following code that downloads file from the internet public boolean copiar(){ boolean teste = false; try { String local = System.getProperty("user.dir") +"\\PDV.jar";; String archive =…
-
2
votes1
answer62
viewsDoubt regarding the Java two-dimensional array
I have this two-dimensional array and wanted to create a different object for each of his entries, but I’m having trouble doing this with a for. Scanner scanner = new Scanner(System.in); Predio…
javaasked 5 years, 2 months ago Joao Spirit 101 -
2
votes0
answers36
viewsIF inside While Selenium
I am checking two fields using Selenium, when I have run the script I noticed that it never enters the IF condition, even meeting the requirements, always goes straight to ELSE. Can anyone tell me…
-
2
votes2
answers177
viewsWhy can’t you access a class attribute in the inherited class?
I have this class: package auladezoitodonove; public class Conta { // atributos private int numeroConta; private String nomeCliente; private int identificador; //Construtores void Conta (){…
-
2
votes1
answer170
viewsIntersection between time
I am in doubt about what to use in creating a film simulation project. So far I have a class Sessao: package entidades; import java.time.Duration; import java.time.LocalTime; public class Sessao {…
-
2
votes0
answers111
viewsIf + Boolean in Java
Good evening, I’m having trouble with my code. I’m using 2 classes to develop a program that accounts for a team victory (Soccer Scoreboard style). My problem is at the time of "if" and "Else". When…
javaasked 5 years, 1 month ago André Gustavo 21 -
2
votes1
answer357
viewsPass parameters in the Retrofit2 GET method for Android
Talk to me, baby? I’m trying to pass a parameter in the retrofit, but I’m not getting it. I confess that I’m very beginner in Android. I did a little research, but what I tried didn’t work out so…
-
2
votes1
answer305
viewsHow to identify if the certificate is A1 or A3?
There is a safe way to identify from an object X509Certificate, if the certificate is A1 or A3? I’m using the function below, but very prone to failures: // Certificados podem ter descrições…
-
2
votes1
answer1387
viewsSpring Boot, ultilizar outro campo de busca além do @id
I am making an API with Java with Spring boot and I would like it to search for CPF and not ID; http://localhost:8080/pacientes/ID http://localhost:8080/pacientes/Cpf (sera informado pelo usuario)…
-
2
votes1
answer363
viewsI can’t remove leaf in binary tree
I’m trying to remove a leaf from the tree, I made a code that apparently, in my head is right, only it doesn’t remove the element I want. Here is my class No: package arvore; public class No {…
javaasked 5 years ago Gabriel Henrique 101 -
2
votes2
answers56
viewsAdd element to an Arraylist only if it does not exist (Android)
I am programming a bluetooth app in Android Studio. I have an arrayList and I place devices that have been discovered in a bluetooth connection. It turns out that when I perform the task of…
-
2
votes1
answer63
viewsHow do I tell the compiler that every Observablelist<O> I pass as an argument will contain a certain method?
I have the following research method: public class Pesquisa { private static <O> ObservableList<O> pesquisarPorNome(ObservableList<O> listaObservavel, String pesquisa) {…
-
2
votes1
answer258
views -
2
votes1
answer120
viewsHeritage is slowing the startup of my SPRING BOOT application
I’m working on an automatic text messaging system, in my class hierarchy I have an abstract class at the top called TaskNFSBusiness which sets the rules for messages that are not in real time, it is…
-
2
votes2
answers748
viewsError Type 3 - Activity does exist
Every time I try to run my app on AVD or on my phone to test the following message appears to me: Error while executing: am start -n "com.example.vantajoso/com.example.vantajoso.MainActivity" -a…
-
2
votes1
answer1199
viewsHow to Map One to Many Correctly in Hibernate
Good afternoon, I am creating a very simple Restful API that implements an online course system, where I have only 2 tables "Courses" and "Teachers" (And I am trying to learn Latin in the process):…
-
2
votes2
answers53
viewsShow a missing address
I am doing some algorithms in various languages and in Java I come across a problem, in my function researcher when the value is not found in the list it should return me a None or null, but I can’t…
-
2
votes1
answer258
viewsRequest made to Spring Boot is returning another endpoint API
I set up a test scenario to treat an error that was happening on my frontend. Situation Problema: The problem was that I was making a requisition for a route ‘/api/v1/telefones’, Spring ends up…
-
2
votes1
answer145
viewsRemove tag in XML generation with Xstream
How can we remove the tag <list> automatically generated on XStream during the serialization process? I have three classes for this scenario: one for test and two to feed data that will be…
-
2
votes2
answers71
viewsObject array gives error when I try to access an element of it
package br.com.cursoemvideo; public class Olho { private String cor; private boolean funciona; public String getCor() { return cor; } public void setCor(String cor) { this.cor = cor; } public…
-
2
votes0
answers54
viewsQuery Existence of PSQL Table
Well, I searched many places until I found the answer to my problem and I found interesting the idea of posting here what I found to help Unity, in case someone needs to perform a similar CRUD,…
-
2
votes1
answer67
viewsATM simulator in Android Studio
I’m setting up a basic ATM simulator in Android Studio, where the user must enter the password, which is already pre-defined, in the case is "Java". If the password is correct, the message "Correct…
-
2
votes1
answer352
viewsHow to separate the name of packages in the Intellij IDEA directory tree?
I am using Intellij IDEA to program in Java and want to create several packages inside each other, where each of them will contain classes and other file types. The problem is that when creating…
-
2
votes2
answers183
viewsHow to resolve "There is no default constructor in ..." error in Java?
I have an abstract class called Veiculo which has two builders: public abstract class Veiculo { // Atributos ... public Veiculo(Marcas marca, int velocidade){...} public Veiculo(Marcas marca, int…
-
2
votes1
answer164
viewsIn what order to dispose the methods of a Java class?
In which order to dispose the methods of a Java class? Whereas a class can have: constructors, static methods, private methods, public methods, abstract methods. For example: public class Classe {…
-
2
votes0
answers131
viewsHow to change the color of the action bar in android studio
I am a student and developer beginner and I have a project that I have to do that basically consists of changing the color of the Action bar (Top Menu) by selecting one of the 3 radiobutton (single…
-
2
votes1
answer58
viewsHow to always register data in the last generated Event?
In my code every time I perform a criminal record a document is created. I wonder if you have how to register information in the latter document generated instead of generating another. I’m doing it…
-
2
votes1
answer159
viewsWhy do classes with underline ("_") in Java become "_1"?
I’m using JNI, using C and Golang, by default we use something like arquivo_windows.go or arquivo_android.go, so I preferred to also call the Java files the same way. So I created a class named…
-
2
votes2
answers571
viewsHow to handle multiple conditionals (if and if if followed) in Java and how to compress them?
Currently I have a small group of classes that implement a game of Snake with two players. I am implementing the movements as the keystrokes, currently the code is like this: // #----- Classe…
-
2
votes0
answers85
viewsDoubts about authentication for a Java application with Spring Security (stateless)
I will start a new project and came to doubt regarding the best way to work the authentication/authorization part. The project will be developed in Java with spring (boot), backend and frontend…
-
2
votes2
answers1221
viewsCode revision of the CPF class in Java
You can review the code of my CPF class? A point of criticism is the use of regex which may be unnecessary. But in my view it makes the code shorter. Another point is the adoption of a class for…
-
2
votes0
answers115
viewsRedirecting HTTP requests to HTTPS in Spring Boot - (Wildfly server)
I want to deploy a Spring Boot app in Wildfly that features HTTP request forwarding to HTTPS. Here is the application.properties: server.port=8443 server.ssl.key-alias=https-example…
-
2
votes0
answers66
viewsUsing this in Java
Hello, in the code below, I just put this in the size attribute because it has a parameter with the same name as it, so that the compiler does not get confused. But I doubt if I put myself in others…
-
2
votes2
answers116
viewsIn Java, what is the purpose of calling interface methods on objects from other classes?
Follow the code I’m studying: public interface Node { public abstract int eval (); } public abstract class Unary implements Node { private final Node child; public Unary(final Node child) {…
-
2
votes1
answer68
viewsHow to use Try with while and vectors
I need to create a code where the user enters 4 whole numbers and if anything else is typed an exception treatment. I’m having problems with the catch, I’m not able to do that when the exception…
-
2
votes2
answers389
viewsHow to display user name initials without their connectors?
From a name entered by the user, display your initials but without your connectors. For example: josé da silva -> JS I was able to generate the code to print the initials but I’m not getting the…
-
2
votes1
answer65
viewsHow to implement java exception handling within a swtich-case?
I have to do a treatment for possible exceptions within a calculator, one of them would be the division by 0, in the case "Arithmeticexception", but I’m not able to make it work, even after…