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
-
0
votes1
answer236
viewsAdd objects of different types in the same vector
I can’t add class Video within the vector. public class SongDriver { public static void main(String[] args) { Playlist lista = new Playlist(); Musica num1 =new Musica("Agua de beber","Antonio Carlos…
-
0
votes1
answer88
viewscom.google.firebase.database.Databaseexception: Failed to Convert a value of type java.lang.String to long
Error I’m wanting the Android app to take the data from Firebase and show them in a list and this is the error. com.google.firebase.database.DatabaseException: Failed to convert a value of type…
-
0
votes1
answer51
viewsImplementing get method
I need to adjust the video time according to some rules, as I do to implement these rules in the code, I tried to put in the get method but no change. public class Principal { public static String…
-
0
votes1
answer160
viewsSet an attribute of another class
I am building a list in JSF, which uses attributes of two classes (ItemdoPedido and Produto). Man ManagedBean is class-based ItemdoPedido, then the difficulty is in setting and recovering the class…
-
0
votes1
answer646
viewsDisable infobar from Chrome when running automated testing
I tried to implement a method that will maximize the Chrome window and deactivate infobar when starting tests, but neither of the two actions will happen when running. Actions are in the method…
-
0
votes1
answer176
viewsuses unchecked or unsafe Operations
I am developing an application in Android Studio with Firebase that is presenting the following error uses unchecked or unsafe operations…
-
0
votes2
answers213
viewsJava JSP return of age
I redid the class Idade and made a test with console and worked right the part. But JSP is showing error and I don’t know how it will do and how I will put in JSP to return age. //Classe Idade.java…
-
0
votes0
answers69
viewsVolley: onErrorResponse is returning the error as null
My server is registering normally, but when trying to send a record to register using Volley, it drops to onErrorResponse and the object error.getMessage() is returning null. My java code: private…
-
0
votes1
answer356
viewsCannot resolve method
I’m making an application for Android in which there is a Fragment to add a task (with title and description), and a Fragment that lists all the tasks stored in a Singleton. In Tasks Fragment when…
-
0
votes1
answer41
viewsInsert using Many to Many Annotation does not work
Hello, I have a Many to Many relationship between TEAM and NEWS. I am trying to create a method to insert a "NEWS". I am using Hibernate with Annotation to map the classes. The Insert works and…
-
0
votes0
answers70
viewsUpload.properties file
I’m having trouble reading a.properties. file.I created a separate class with a static method. However, it throws an exception and returns null. Follow my code below. public class LoadLog4jProperty…
-
0
votes0
answers552
viewsHow to test with Junit in a C R U D?
I would like to know the condition to use within the test. Got the class Customer package br.myhome.web.model; import java.sql.Connection; import java.sql.PreparedStatement; import…
-
0
votes1
answer58
viewsBuild error
Guys, I’m making two mistakes and I don’t know how to fix it. Follow the code below: import java.io.*; import java.util.*; public class Pilha{ int elementos[]; int topo; public Pilha(){ elementos =…
javaasked 6 years, 2 months ago Lucas Nascimento Távora 51 -
0
votes1
answer120
viewsMake the Tostring() method return two fields separately from a typed object
I need to get the Tostring function to return the size and color separately, as I am filling a spinner with them. A spinner is filled with colors and another with size. However if I put: public…
-
0
votes1
answer61
viewsCircumference area
Good evening! I’m starting in Java, and I’m trying to complete the Circumference Area Code of the URI. You’re giving a lot of trouble: Exception in thread "main" java.util.Nosuchelementexception at…
-
0
votes1
answer235
viewsHow better is text-to-Speech in my android app, not respecting the punctuation marks?
app already speaks what I write, but if I write a question with punctuation mark (?) does not pronounce as a question, the pronunciation is very fast, how do I improve it? public class MainActivity…
-
0
votes1
answer193
viewshow to build and run an IDE Maven project
Good afternoon, I’m trying to generate an application for studies using Maven, but this disastrous and very frustrating. I’m trying to create a web project using Maven, but I can’t do anything to…
-
0
votes0
answers148
viewsHow to get the sum of a Bigdecimal column
I need to add a data column BigDecimal Mysql, which has already been filtered from a given range. I am trying with SELECT SUM(preco_total) FROM venda; in the code below, but I’m not getting results.…
-
0
votes1
answer30
viewsRemove item from an Adapter class
I’m trying to remove the listview item, but when I test the app does nothing... My class Productoadapter: public class ProdutoAdapter extends ArrayAdapter<Carrinho_Item> { private Context…
-
0
votes1
answer64
viewsAccess page in another project
I am one developing a system that is divided into three modules (Distinct projects), using JSF Framework (Java Server Faces). I have a main module that has a login screen, which in turn has an…
-
0
votes2
answers99
viewsVariables print often
The variables media and contador, after the execution, they print many times and I don’t understand why. I wanted them to print only once at the end of the execution of the whole code. My code:…
javaasked 6 years, 1 month ago Fabio Ribeiro 1 -
0
votes1
answer44
viewsWhat’s wrong with the code? He was supposed to check while, but when I type continue or cancel he keeps repeating!
System.out.println("Qual produto você deseja verificar a disponibilidade? "); System.out.println("Digite: Prato, Copo, Talheres, ou Cancelar para sair! Ou continuar " + "para dar seguimento a…
-
0
votes1
answer365
viewsinsert multiple objects into an object array
When I insert the next object it returns a Boolean false public class Main { static Aluno aluno = new Aluno(); static Scanner s = new Scanner(System.in); static RepositorioA repositorioA = new…
-
0
votes0
answers29
viewsI can’t solve a notification line
The error is on the line: notification.setLatestEventInfo(context, contentTitle, contentText, contentIntent);. I couldn’t fix it. Any change I make makes a mistake. // Define Notification's message…
-
0
votes1
answer432
viewsHibernate Does Not Change Automatically in Database
I’d like Hibernate to not make any changes directly to the database, which means I’d like him to follow what’s in the database. Example : If in my entity I have the following situation @ManyToOne…
javaasked 6 years, 1 month ago Josemar Sabino 77 -
0
votes3
answers145
viewsSave character by character within an array
(my return) I would like to convert a string into an array of characters, a character in each index. I would like 'hi' to be converted to var[0] = 'o', var1 = 'i'; I am making an array calculator…
javaasked 6 years, 1 month ago Jéssica Developer 25 -
0
votes1
answer67
viewsI need to access indexes from a java array
public class Conteudo { public List<String> Matriz(String[] array){ String CaminhoArquivo=("C:\\Users\\jessica borges" + "\\Downloads\\CalculadoraMatrizes-20190315T112959Z-001" +…
javaasked 6 years, 1 month ago Jéssica Developer 25 -
0
votes1
answer1226
viewsUnique index or Primary key Violation
I am getting the error below when trying to create a new item in a table, in this table I have some previously added items. 2019-03-17 00:05:09 WARN o.h.e.jdbc.spi.SqlExceptionHelper - SQL Error:…
-
0
votes1
answer67
viewsI want to call a public List<String> method in main
public class Conteudo { public List<String> Matriz(String[] array){ String CaminhoArquivo=("C:\\Users\\jessica borges" + "\\Downloads\\CalculadoraMatrizes-20190315T112959Z-001" +…
javaasked 6 years, 1 month ago Jéssica Developer 25 -
0
votes1
answer39
viewsBad operand : does not accept accounts or comparisons!
I’m inclined to solve the following problem: João Papo-de-Pescador, a good man, bought a microcomputer to control the daily income of his work. Every time he brings a weight of fish greater than…
javaasked 6 years, 1 month ago Tadeu Agostini 50 -
0
votes1
answer118
viewscompare Array with another Array com for in Java
Everybody, Good afternoon. I am wanting to compare 2 Array, where 1 array has randomly set value. I want to use for so I don’t have to repeat 100 times. But I don’t know, because it always shows me…
-
0
votes1
answer52
viewsHow to send a received variable in the main method to another class to be treated
Code: public class Matrix { public static void main(String[] args) { Menu(); } private static void Menu() { CreateMatrix creatematrix = new CreateMatrix(); int escalar = 0; int option = 0; Scanner…
javaasked 6 years, 1 month ago Jéssica Developer 25 -
0
votes2
answers96
viewsMerge Sorted Java
I need to merge in java, with values of an Instance of a class, Queue a and Queue b, I made a method to insert(), in the Queue class. and would like to access the values of a and b. And assign these…
-
0
votes0
answers15
viewsNullpointerexception when displaying Notification with Pendingintent and Broadcastreceiver
I am consuming an API and called Broadcastreceiver whenever the user connects to the internet. However, when displaying the notification is appearing: "java.lang.Nullpointerexception: Attempt to…
-
0
votes1
answer24
viewsButton in the Spinner reset Mainactivity in a Dialogfragment
I have two buttons in Mainactivity, the first opens a custom Dialogfragment with some spinners and the other button resets the spinner of this Dialogfragment. When I click the reset button it calls…
-
0
votes1
answer34
viewsUse findViewById in Android Studio’s standard Mapsactivity
I’m using the standard Maps template available on Android Studio, and in the activity_maps.xml added a EditText with the id towhere. In the Mapsactivity class I just added a…
-
0
votes1
answer160
viewsConvert program to other encoding in java Ex:(UTF-8 to ansi)
Good afternoon guys, my code from nothing passed to a different encoding, which I believe to be UTF-8, at the time of executing the code happens the following error: unmappable character for…
-
0
votes1
answer27
viewsHibernate Does Not Create Schema Tables
What I realized is that Hibernate doesn’t seem to create tables the way they should be presented in the database. I’m using Mysql and realized the following: Example of the structure: Table Course…
-
0
votes1
answer127
views -
0
votes1
answer181
viewsDistance between a line and a point in three-dimensional space
Let’s say there are three points in a 3D space (dots A, B and P). Let’s also say that there is a straight line through A and B. What I’m trying to do, actually, is find out if a reta AB intercept…
-
0
votes2
answers129
viewsCode does not work and returns no error (Java)
I’m new to Java, and I can’t run this code: package exercicio.pkg4; import java.util.Scanner; public class Exercicio4 { public static void main(String[] args) { Scanner ler = new Scanner(System.in);…
javaasked 6 years, 1 month ago Julio Faria 21 -
0
votes2
answers105
viewsChange Textview with Listview event
I would like to change the total value whenever an item is changed... Class that sums up: public class Somar { private List<Carrinho_Item> lista; private double total = 0; public…
-
0
votes1
answer35
viewsConnection error send java email. Can anyone help me?
I am making a program that sends email through java, using these two classes but when I run it is giving this error. Can anyone help me? Error: Exception in thread "AWT-Eventqueue-0"…
-
0
votes1
answer468
views(Android Studio) Webview loads the page and does not open
I am making an application that gathers some sites, but some of them keep clicking on Webview and does not open. As an example I will use the Urpay. I’ve seen this site being opened by another…
-
0
votes1
answer47
viewsKEYBOARD DECREASES TO SETAR android:inputType="number""
Putting such a configuration in an Edittext, when compiling the keyboard is "dropped" on the screen follows the xml of Edittext <EditText android:id="@+id/edtIP" android:layout_width="652dp"…
-
0
votes2
answers235
viewsHow to convert byte[] to mp3
I’m writing an app where I have a list of byte[] and need to create files .mp3 from these byte vectors. When prompted, the app zips all these files into one file .zip, but later the player is not…
-
0
votes1
answer808
viewsHow to clean the data stored in memory, in cache or then reset an application (App) in android studio?
I am developing an application in android studio and need to solve this problem. I am using an internal database in Sqlopenhelper to store the products chosen by the user and show in a shopping…
-
0
votes1
answer40
viewsNullpointerexception when running a Selenium Webdriver test
I have a certain difficulty in instantiating the driver in another class. What happens is the following: I have two definition classes of steps First: public class TranscricaoSadtStep { static…
-
0
votes2
answers143
viewsStored Procedure Doesn’t Deliver Results You Should
-I am very new in SQL, Spring & Java, I am trying to set the results of a list that returns in a Query I created -this query returns a list with the referenced object -the parameters are all…
-
0
votes1
answer44
viewsHow to add objects to a repository class? And how can the user choose the amount of array in which he will add the data?
Hey, here’s my question. I would like to know how to read the user data in main as follows: I have an array of up to 10 for the user to put the book data, but he can choose less. And another, after…
javaasked 6 years, 1 month ago Luis Gomes 7