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
-
-1
votes1
answer64
viewsQuery error for a JSON URL "getContentHandler, getContent"
I am starting the development of an app that performs queries to various websites with JSON return and treat this information in several ways. To test the Urls I use the code below, works well with…
-
-1
votes1
answer135
viewsConverting from Java to Groovy. Problems with dynamic type promotion. How do I disable it?
I’m converting an old Java application to Groovy. The syntax conversion is smooth. The problem is dynamic Groovy typification. Let me give you an example, I declare a method foo and its overload:…
-
-1
votes1
answer220
viewsPass Array String by parameter
public List<String> Matriz(){ String CaminhoArquivo=("C:\\Users\\jessica borges" + "\\Downloads\\CalculadoraMatrizes-20190315T112959Z-001" + "\\CalculadoraMatrizes-20190315T112959Z-001" +…
javaasked 6 years, 1 month ago Jéssica Developer 25 -
-1
votes2
answers1607
viewsCount the number of characters in a String?
I need to count the total number of characters of a String when the word is typed. I would like to know how to create the code, I believe it is a. public class ExercicioDeString { public String…
javaasked 6 years, 1 month ago Julio Vieira 39 -
-1
votes1
answer88
viewsjava.lang.Nillpointerexception error
My code is returning this error: Exception in thread "main" java.lang.Nillpointerexception at Banco.java:36 I’ve redone the whole project, all the classes, I’ve watched the videos countless times,…
javaasked 6 years, 1 month ago Matheus Azevedo 1 -
-1
votes1
answer49
viewsError:java.lang.Nullpointerexception at user.Mein.main(Mein.java:15)
Can someone enlighten me a little, is giving error in the line where I start to fill the user array. public Usuario(String nome, String sobrenome, String cargo,int idade,double salario) { this.nome…
javaasked 6 years, 1 month ago Luis Gomes 7 -
-1
votes2
answers120
viewsManipulation of Arraylist
Good morning Friends, I am having a lot of difficulties in making this application work, I am not able to calculate the days of absence of the students, my difficulty is in the class Agenda in the…
-
-1
votes1
answer95
viewsJava in Eclipse: displaying many warnings
I’m starting to study Java using the Eclipse IDE, which has helped me a lot at this beginning in creating classes and screens. Would you like to know if it is normal for it to be displaying many…
-
-1
votes1
answer85
viewsI’m not able to take the Edittext value of the aux variable and compare in the if
When you type 0 or 1 of Edittext is to enter IF and does not enter. private TextView nome1; private TextView nome2; private EditText vitoria; private Button salvar; private TextView primeiroLugar;…
-
-1
votes1
answer47
viewsNullpointerexception error in the Java language using Android Studio
I’m using android studio to program apps and recently all apps I try to program, while trying to run on emulator and real device, receive the same error. 04/23 00:21:55: Launching app $ adb shell am…
-
-1
votes1
answer66
viewsAndroidstudio - Swap url for image in local project path
Good afternoon, everyone, I have a string that I use to set the image of some buttons: String imagem[] = {"https://cdn.pixabay.com/photo/2015/12121.jpg",…
-
-1
votes2
answers150
viewsMake Insert with foreign key
I am trying to make an insert with foreign key but I am not succeeding, giving the following error GRAVE: null org.postgresql.util.PSQLException: ERROR: insert or update on table "agendamento"…
javaasked 5 years, 11 months ago Victor Marcantonio 1 -
-1
votes1
answer47
viewsHow to rank the most useful comments from a table?
A following scenario: Each Product has a comment, each comment will receive a like to inform if it was useful (it is optional to inform if you liked the comment) I have a table called Customerreview…
-
-1
votes1
answer432
viewsHow to resolve Exception in thread "main" java.lang.Nullpointerexception error in my program?
public class ClassMain { public static void main(String[] args) { CPessoa[] Pessoas = new CPessoa[10]; int cont=0, j=0; for(int i=0; i<10; i++){ Pessoas[i] = new CPessoa(Pessoas[j].nome, cont); }…
javaasked 5 years, 11 months ago Caio Noronha 1 -
-1
votes1
answer90
viewsProblem with if in Java
I’m trying to make a program like "lottery", locked in a mistake there on if. If you can help me, follow the code: package praticando; import java.util.Random; import java.util.Scanner; public class…
-
-1
votes1
answer133
viewsTurn an SQL command into Lambda or Java 8 Stream
I’m starting in Java 8 and would like to turn the SQL command below into a lambda function: SELECT * FROM Correspondencia c, (SELECT entidadeOrigem, MAX(m1) similaridadeMaxima FROM Correspondencia…
-
-1
votes1
answer41
viewssave a record to a list of an entidate
Good evening, I’m practicing my study and I came across a problem. I have an entity User: @Entity public class User { @Id @GeneratedValue(strategy = GenerationType.IDENTITY) private Long id; private…
-
-1
votes1
answer110
viewsMysql Date type field returning incorrect value in Java
I am trying to read data from a Mysql table with Java, but the Date field is returning the following code:…
-
-1
votes1
answer148
viewsHow to read a certain line of multiple files in Java
In the Stock folder, I have several.txt files. I would like to read each row of these files. The question is: how? NOTE: if I could save the name of each file, I might be able to solve the problem.…
-
-1
votes1
answer45
viewsMysql data is not inserted
Hello, I am trying to insert data into mysql by netbeans, but it always returns the "null" error. When I refresh mysql the table continues without the entered data. There is no error in the syntax,…
-
-1
votes1
answer37
viewsNull array in a constructor (java)
The purpose of the code is to pass a arraylist of Sessao for the builders sala2D and 3D(in the constructor, the name of the arraylistof Sessao is "Session"). But after some tests it is found that…
-
-1
votes1
answer27
viewsHow to read an object from a file?
Personal when I try to read the objects saved in a file appears the following error message. Nome: Gabriel Código: 123 Telefone: 12345678 java.io.StreamCorruptedException: invalid type code: AC at…
-
-1
votes1
answer394
viewsAdd 2 attributes and return to a third attribute
I am trying to add two attributes and return the value to a third attribute, follow example, it is possible and if yes what I am doing wrong? package testesomaatributos; public class…
-
-1
votes1
answer40
viewslogin/password data validation
created 2 classes one of connection and the other how I could do a login/password validation with these two classes connection /* * To change this license header, choose License Headers in Project…
-
-1
votes1
answer39
viewsjava database connection
Well I did a class to make the connection with fingered bank: /* * To change this license header, choose License Headers in Project Properties. * To change this template file, choose Tools |…
-
-1
votes1
answer34
viewsI have two methods to do a validation like leave in only one?
connection class: public class ConnectionFactory { private static final String DRIVER = "com.mysql.jdbc.Driver"; private static final String URL =…
-
-1
votes1
answer73
viewsTake last result and increment with php, javascript and mysql
As I do to take the last value inserted in SPAN and add another 10 to save in BD, the insertion is all ok, I need to delete the input and each time BD add another 10. Example: Product 100 by…
-
-1
votes1
answer53
viewsProblem with a one-way structure
Well I made a method to change password where it does a select in the database to see if the login and password entered are equal in the database String sql = "SELECT id_usuario,nome,senha FROM…
-
-1
votes2
answers250
views"algaworks" - Bigdecimal - Sum of values
I am trying to add the values added in the column "Value", IE, to each entry of a recipe the total field below needs to update doing the sum of the values in the column value, however I am with the…
-
-1
votes1
answer35
viewsError does not appear in login page and program closes when run in emulator
I am making a login page that if the data is correct or incorrect appears a Toast displaying the result. The problem is that there is no error (when there is any) and when run in the emulator the…
-
-1
votes1
answer262
viewsValidation of the data itself entered in the field (character limit)
Suppose I have a field that has a limit of 15 characters. In my test i add 16 characters. How do I validate that they were entered only 15 characters in the field?…
-
-1
votes1
answer75
viewsHelp with JSF Login System
I am creating a jsf login system, which I validate the data through a bean and if(has record) redirects to the home page, Lse goes to the error page, but always enters Else, I found that the object…
-
-1
votes1
answer136
viewsHow to make a program in java that tells you which positions are ahead and behind a word
This method tells how many words you have in a sentence: public static int pesquisaPalavra(String palavra) { String frase = "Deus é bom o tempo todo, o tempo todo Deus é bom"; String[] arrayString =…
-
-1
votes2
answers198
viewsJAVA - Swing-free timer with MVC
I’m studying java and I saw myself in a situation that I don’t know how to solve... I have a timer where I intend to do it following the rules of MVC, but I can’t update Jlabel when I separate the…
-
-1
votes1
answer62
viewsHow to persist data using JPA concatenated key in the @Manytomany relationship?
I have the first entity private static final long serialVersionUID = 2405172041950251807L; private static final String CAMPO_CODIGO = "CODIGO"; @Id @GeneratedValue(strategy =…
-
-1
votes2
answers1504
viewsObject array in JAVA
You guys talk beauty ? So, I’m a beginner in java development and my first cruel question that I faced in a question in the course was the following. "Register data from a current account or savings…
-
-1
votes1
answer22
viewsProblem accessing data from an object in an object array
I have a Store class that has an array of type Product (which has name, code, price and quantity) and I need to access the given name of the objects of this array. The following code is giving…
-
-1
votes1
answer40
viewserror: ")" expected } <
Guys, I’m trying to make a program that by clicking the confirm button, open another Jframe, but keeps giving the error error: ")" expected } ^ and error "teladelogin.java:48: error: class,…
-
-1
votes1
answer256
viewsApplication normally runs on Tomcat embedded in Spring Boot and does not run on Tomcat on my Server
good afternoon. I’m having a problem with an application using Spring Boot 2. Basically it is a Restapi with some "scheduled methods". In the Spring Boot embedded Tomcat it works normally, runs the…
-
-1
votes1
answer625
viewsHow to install java 8 on Ubuntu 19.04?
First of all, I know it seems a rather silly question, but I am a Windows "user", I have the dual boot on my machine.I really admire Unix, and I intend to migrate to it for good. I was using Ubuntu…
-
-1
votes1
answer90
viewsHelp me in a logic to solve my problem
Well, I’m creating an application for base conversions and I kind of created a mini keyboard with the keys to Hexadecimal (A, B, C, D, E, F), but it’s a hexadecimal text field when I type 3 and I’ll…
-
-1
votes1
answer28
viewsuse methods of one class in another
I’m making a simple application, and when it comes to using the methods of one class in another, it’s not working. I have the following class: import org.bson.Document; import…
-
-1
votes2
answers654
viewsHow to remove last element from a chained list using position?
I am wanting to remove the last element from a chained list by typing position n: when I type 1,2,3,4,5 of and n=2, I want it to stay 1,2,3,5 but it’s giving 1,2,3. import java.io.IOException;…
-
-1
votes1
answer80
viewsError renaming txt file in JAVA
Hello! I need to rename a file txt, that txt is scheme for system log. Each day has its own log.txt. I am using the following parameters to validate the file and rename, if the file exists and if…
javaasked 5 years, 8 months ago Ronison Matos 313 -
-1
votes1
answer80
viewsHelp with War game in Java
I am trying to make a game of War in java where the game map is a simple vector of 1 to 16 each number being a country, I made a Random to draw the player the country he will start, but how to…
javaasked 5 years, 8 months ago João Felipe Leonello 3 -
-1
votes1
answer155
viewsHow to update a database (Sqlite DB) using the Workmanager library?
I am using the workmanager library to show a notification to the user indicating the time to take his medicine. I am also using the Sqlitedatabase library to store medicine information such as:…
-
-1
votes1
answer386
viewsError generating pdf report from a jsp page
I have a problem generating pdf report using jsp and jasperreport. Initially, on my desktop where my server was glashfish, the code ran well, but when publishing the page on a Tomcat server, it gave…
-
-1
votes1
answer55
viewsNullpointerexception when generating graph
I’m creating a graph that pulls data from the database, but at the time of generating the graph gives the following error: Exception in thread "AWT-Eventqueue-0" java.lang.Nullpointerexception The…
-
-1
votes1
answer315
viewsHow to generate the jar file by Maven?
I need to generate a file jar in the project folder as shown in the image below; I don’t want to be depending on the bash command mvn clean install, i would love to put the settings in the pom.xml…
-
-1
votes1
answer35
viewsDeserialize an Object of Another
I’m trying to deserialize three DTOS classes to export to a JSON file, I was able to do much of the process but when I try to export one class inside another I can’t. follows the following…