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
votes2
answers61
viewsWhy do even numbers not have the same output as odd numbers?
I made a program that asks the user for a number that will serve maximum value. And then the program shows which even and odd numbers from 0 to that number. I used printf to have an output like: Os…
-
1
votes0
answers19
viewsProblem with Android Programming. FOR
I can’t generate the amount of EditTexts based on the parameter of for? Where is the error? @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState);…
-
1
votes0
answers19
viewsStatusbar - Change color with scrolling on a Collapsingtoolbar
Currently I have an image on a profile screen and Statusbar is "transparent". Running straight!! Problem: The problem is the scrolling of the screen, because in this case I’ve managed to make the…
-
1
votes1
answer1765
viewsSave android image
I know there’s probably an answer here on the site to my question, but when I researched I saw several ways and got a little lost. I wanted to create a hidden folder and have some ImageButton or…
-
1
votes1
answer990
viewsHow to center the string of the bar action title and how to change its size?
JAVA package togglebutton.cursoandroid.com.togglebutton; import android.support.v7.app.AppCompatActivity; import android.os.Bundle; public class MainActivity extends AppCompatActivity { @Override…
-
1
votes1
answer80
viewsHttpurlconnection returning empty
Message Attempt to invoke virtual method 'int java.lang.String.length()' on a null Object Reference Calling for JSONArray data = new JSONArray(getHttpGet(url)); Code: public static String…
-
1
votes1
answer420
viewsSqlexception error while trying to connect to database
I am creating a project with JDBC. When I run the code it gives the following error message: Exception in thread "AWT-Eventqueue-0" java.lang.Runtimeexception: java.sql.Sqlexception: No suitable…
-
1
votes1
answer337
viewsPass class values when generating a pdf in Javafx
Good afternoon, I created a PDF.java, which has the function of generating a pdf, and in another file (Formulariohotelerioscontroller.java) when clicking on a certain button, I urge the PDF.java…
-
1
votes1
answer245
viewsjava error in connection with SQL Server
I’m trying to connect to a sql server database, but I’m not succeeding. Follows connection class and test method: public class ConexaoBanco { public static final String user = "sa"; public static…
-
1
votes0
answers27
viewsError returning an Array in a? JAVA method
The output of the algorithm is this: [D@28d93b30. I want you to return double[] predicted responses. public double[] CalculoPrevisao(double[] valores){ double[] previsaoPeriodos = new…
-
1
votes1
answer136
viewsOptimize Java code
Good, I am creating an alarm on android e I wanted to know if inves to have to make a switch for each editText se Avia way to check all on a single switch, I tried with a for and was incremented,…
-
1
votes0
answers53
viewsWhen sending Java object from an android app to the database one of the attributes goes as null
Produto produto = new Produto(); produto.setNome(edtNome.getText().toString()); produto.setPreco(Double.parseDouble(edtPreco.getText().toString().replace(",", ".")));…
-
1
votes0
answers407
viewsWildfly loading very slow, VERY SLOW
I was studying JavaEE7 and using the Widlfly 11.0.0.CR1, first without any configuration on the server itself, just running a normal webapp, without many things, a form, with a listing, and the time…
-
1
votes2
answers235
viewsReset variable every time you switch to a method
I’m making a simple program that inserts at the first possible position of a vector, a String. This is the code I have: import java.util.Formatter; import java.util.Scanner; /** * * @author…
-
1
votes1
answer1155
viewsMake the text appear when clicking the button and the image specifies it?
I want to do a project where clicking the button will appear a text and when the text appears I want an image to appear together. ex: random text chosen "the dog is silly" appears the photo of the…
-
1
votes1
answer47
viewsError trying to save data to database via Java
I am trying to save data in the database and is returning the following error: Attempt to create merge Event with null Entity The Bean is like this: public void SalvarCliente(){ try { ClienteDao…
javaasked 6 years, 11 months ago Melk Oliveira 11 -
1
votes1
answer95
viewsproblems with Float Action Buttom (speedDial) - Android
Hello! I found a lib of a float action with speed dial and I’m trying to implement it in my Android project, but I’m not able to interact with the Float Button... follows the code of the fragment…
java android android-fragment android-recyclerview floatingactionbuttonasked 6 years, 11 months ago Mikhael Araujo 333 -
1
votes1
answer164
viewsDoubt Converter and CDI
I’m a few hours testing and trying to understand why this code here isn’t working and I’m getting one NullPointerExcepetion . Someone can sense something wrong ? import…
-
1
votes2
answers342
viewsProblem with @form Primefaces - JSF
I have a problem in Auto update @form of primefaces, it should automatically update the datatable but is not working. Below is JSF and managedBean. Thank you! Products <h:form>…
-
1
votes1
answer954
viewsArchive *.CSV with UTF-8
I created a process that takes the content of a given web page filters what is needed and generates a file *.csv of this content, you work correctly but words that have some accentuation end up…
-
1
votes0
answers35
viewsUnderstanding old JAVA code
I have a code here at the company and I need to understand what it really does. By the method Name I found that it removed the characters outside the UTF-8 pattern or something like that, giving an…
-
1
votes1
answer44
viewsError using Sslclientexisengineconfig
I’m trying to use the class Sslclientexisengineconfig to make a call on an SSL server (I need to make a call where the client uses a certificate to authenticate to the server, vice versa). When…
javaasked 6 years, 11 months ago Nicholas Fuchs 11 -
1
votes0
answers135
viewsIs it possible to encrypt the connection password to the database that is inside a Java application?
I have an application in Java and using the Postgresql database. To connect to the database I use this method: public static Connection getConnection() throws Exception { try {…
-
1
votes1
answer87
viewsProblems when creating application to consume postal services
I am developing an application that aims to consult prices and deadlines of orders consuming the Post Office service. However I am having difficulties to implement the service in the application.…
-
1
votes1
answer860
viewsFibonacci issue in Java
I have a question and her resolution, which needs to be with while or do-while. But I did not understand the resolution, could someone explain to me? I will comment on the specific doubt of each…
-
1
votes0
answers432
viewsPrinting houses in Lleida
Personal to make the printing on a Diebold printer I am using the following code: DocFlavor docFlavor = DocFlavor.INPUT_STREAM.AUTOSENSE; // Atributos de impressão do documento HashDocAttributeSet…
-
1
votes1
answer683
viewsOrientation - Handling hours and minutes Java + Postgres
I am finalizing a Time Sheet project for accounting and it is my first project so I have not yet experienced manipulating date and time in java and database, without further delay: I need to solely…
javaasked 6 years, 11 months ago Dhouglas Silva Gomes 75 -
1
votes1
answer53
viewsHow do I make the methods receive the x and y parameters?
When I ask for the values of x and y, i want to make the operations of the methods receive the values entered by the user. What to do? public class Calculadora { Scanner sc = new Scanner(System.in);…
-
1
votes0
answers306
viewsSet file cell *.CSV as merged
Is it possible for a given cell to be merged into a generated *.csv file? I ask because I am generating a *.csv file where the user should only do one Ctrl + C \ Ctrl + v in the content and paste in…
-
1
votes0
answers31
viewsHow to open external link outside the app?
My project simply opens the page of my blog, and there are several links from other sites with domain other than mine. I want that whenever the user clicks on one of these links, the same opens in…
-
1
votes1
answer204
viewsHow to map REST request response
I am consuming a REST API with RestTemplate and it does not follow good practices, such as using HTTP status codes, for example. Response in case of success: { "435": { "Codigo": "435", "Tipo": "",…
-
1
votes1
answer180
viewsDelete a Hibernate Record Limit (Limit)
I am migrating my web application to the framework Hibernate, but I have several requests SQL with very specific parameters. In one of these requests, I always need to include a new record in the…
-
1
votes2
answers1480
viewsComparison of elements from a JAVA list
I would like you to shed some light on that exercise. I need to print on the console the name and price of the two most expensive products read from a file .csv but it is only printing the last name…
-
1
votes2
answers107
viewsDoubt - Java algorithm
I’m trying to solve a java algorithm that looks like this. Write a program to print the following: 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 0 1 2 3 4 5 6 7 0 1 2 3 4 5 6 0 1 2 3 4 5 0 1 2 3 4 0 1 2 3 0…
javaasked 6 years, 11 months ago Guilherme Ramos 55 -
1
votes0
answers656
viewsProblem using @Jsonignore Spring Boot
I have a @Manytoone relationship between Manga and Author, where Many Manga can have an Author and an Author can have many Manga. I would like to list all the Manga with each Author, and when…
-
1
votes1
answer790
viewsI can’t find solution for "java.lang.Nullpointerexception" Error - Android Studio
The following error appears: java.lang.NullPointerException: Attempt to invoke virtual method 'boolean java.lang.Object.equals(java.lang.Object)' on a null object reference at…
-
1
votes0
answers176
viewsHow to open a screen with navigation Drawer from a button?
I am developing my TCC and do not have much knowledge on Android yet, but following some tutorials I managed to build a basic app. But I’m not getting and I have no idea how to open a screen with…
-
1
votes1
answer68
viewsTransforming Collections into Stream
There would be ways to transform the following code to java 8 Stream? setores = new SetorBusiness().buscarEtiquetaFuncionario(null, codDiretoriaSelecionada, codCoordSelecionada, uf, cidade,…
-
1
votes1
answer96
viewsRandom numbers repeating themselves
Well guys, here’s the thing: I have a method that generates random numbers, and in Activity I try not to repeat these numbers, but it happens that they repeat themselves. What I’m doing wrong?…
-
1
votes0
answers87
viewsvisulaizar PDF in java application - Embedded - Problem in rendering
Hello, I need to view PDF’s in my JAVA application. After some research, putting aside the paid components it seemed to me that the best answer would be this: Displaying pdf in Javafx The colleague…
-
1
votes1
answer107
viewsHow to save to type Numeric in Mysql
Hello, I am using to save the price of a product in MYSQL the type Numeric(9,2) but in my system I am using Double and when printing it appears R $ 2.2 instead of R $ 2.20 what kind of data could…
-
1
votes1
answer200
viewsListview in another Activity
I have a Listview in my activity main when I click a button, it adds data to my Listview, so far everything is correct. How do I show this listview in another activity? I show other data (EditText)…
-
1
votes0
answers161
viewsAngular error
Request URL:http://127.0.0.1:8080/itcd-intranet-ui Request Method:GET Status Code:404 Not Found Remote Address:127.0.0.1:8080 Referrer Policy:no-referrer-when-downgrade view source…
-
1
votes1
answer43
viewsWhen to use void Inject on Dagger
Dagger, can someone give me a hand? I managed to do some 3 very simple projects always trying several to have new problems and learn more, but one part I’m kind of copying because I don’t…
-
1
votes2
answers2178
viewsPersisting a Spring Boot Relationship
I have the following Entity classes Patients @Entity @Table(name = "pacientes", schema = "sau") public class Pacientes implements Serializable { private static final long serialVersionUID =…
-
1
votes1
answer190
viewsError writing and reading CSV file
I have the following problem in writing a CSV file. The file appears this way: NULL My class of Archive import java.io.BufferedReader; import java.io.BufferedWriter; import java.io.File; import…
-
1
votes1
answer729
viewsError: "Cannot find Symbol" - Class Instance within Main Class, using Linux terminal
I have an exercise to solve, which consists of creating a simple Java language calculator. I have to send the two numbers through Terminal as arguments to my program. I am using the following build…
-
1
votes1
answer295
viewsnon Static method write cannot be referenced from a Static context
I’m a beginner in android and in programming overall, I was following a classroom video to record a string in a txt file, when I came across the following error: Error:(49, 31) error: non-static…
-
1
votes0
answers379
viewsTake the bytes from the file and generate a hash
Guys I am reading a txt file as follows, as I would to save the bytes of the file and generate a hash sha-256 the class it generates I also already own the code, as I do for storing in an array of…
-
1
votes1
answer289
viewsHow do I show an image that is in the database using jsp?
Well, here’s the thing. I’m using JSP, SERVLET and Mysql to insert images into my project, it turns out I just keep the image path in the database, and then call this path to show the image. Then…