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
votes2
answers345
viewsBreaking a string containing a polynomial
I created a class with two properties as in the example below: class Polinomio { private int coeficientes; private int expoente; } I will create a list to receive a polynomial type where I will…
-
3
votes1
answer1325
viewsCreate Generic type in Arraylist to persist data
I’m having trouble understanding the concept of Dao and how I could create a specific type to store my data, I’m initially using a String Arraylist and need to adapt it to an Object Product…
-
3
votes2
answers117
viewsWhat’s wrong with this while? The || is not working
Scanner input = new Scanner(System.in); String str = input.nextInt(); while ( (str.nextInt() != 5) || (str.nextInt() != 10) ){ str = input.nextInt() } The code should invoke the method nextInt()…
-
3
votes1
answer228
viewsMaven Web Application with Github Repository and Hosted in Openshift
I have a Java web application (wildfly server) created with Maven, locally versioned with Git and remotely on Github, I’d like to know how to host this application in Openshift and deploy every Pull…
-
3
votes3
answers9295
viewsEmail verification in Java
I am doing a simple test to check if the user has typed a valid email. So I have an error of syntax in token "@" invalid Assignmentperator. Code of the main class: public class Email { static String…
-
3
votes1
answer218
viewsFormatting values in the millions
I want to format values in the millions. Example: The result of a calculation would be 1.960,35. But the way out is 19603565.2315789. I’ve been using DecimalFormat, but it was for smaller numbers.…
javaasked 8 years, 8 months ago willian.as 45 -
3
votes2
answers1291
viewsBigdecimal comparison returns unexpected result
In one of my methods I make the following comparison, as in the example below: public static void main(String[] args) { BigDecimal valor = new BigDecimal("100"); exemplo(valor); } public static void…
-
3
votes1
answer238
viewsHow could I implement Command (Design Pattern) in this work?
I’m doing a work in Java, where we should implement 3 Design Patterns from the software we created earlier. The software I created is basically a CRUD for movies. In one tab, you add (Insert) and…
-
3
votes2
answers3134
viewsHibernate Validator @CPF that can be null
I’m using the Hibernate Validator with the annotation @CPF. It is validating beauty, the problem is that my system can have the CPF field without value (null) and Hibernate does not accept it. I put…
-
3
votes2
answers2269
viewsHow do I login to a system via an HTTP request?
I’m performing an HTTPS get request for the following address, my initial intention is to receive the html data from the page. I followed the tutorial of Mkyong, but I get the answer code 302, I…
-
3
votes1
answer940
viewsHow to create and popular a table using jquery and database?
I need to create an HTML table that populates the rows and columns with data coming from a specific table in my database. But I want that whenever a new data is inserted in this table of the…
-
3
votes2
answers5194
viewsWhat is the purpose of the "persistence.xml" file?
I’m studying about the Hibernate, And along the way I came up with several doubts, one of my doubts, and that is important for my learning, is about the purpose of the archive persistence.xml which…
-
3
votes3
answers334
viewsError using LIKE to search by name
When I used Mysql I could use the LIKE ? to do searches by name, code, etc... Now in SQL Server I’m not getting. I have a Textfield and a search button, I want to take the value of textField and…
-
3
votes1
answer104
viewsNullpointerexception when trying to open database
I’m trying to include in DB an item that was selected, but when trying to open the database using the .open(); I’m getting an error of NullPointerException. After the user selects which item to…
-
3
votes1
answer234
viewsHow to override the remove() method from Iterator?
I created a repository (RepositorioObjeto) and it implements the interface Iterator on the object the repository stores (Iterator<Objeto>). So I had to override the methods next(), hasNext()…
-
3
votes2
answers364
viewsslideToggle hides multiple Ivs when it should hide/display only one at a time
I have several records in PHP, and when clicking one link "More information" opens a <div> hidden, but when clicking on this link opens the <div> hidden from all records. My Javascript…
-
3
votes2
answers3878
viewsCatching first and last date of the previous month
I am using in Eclipse Selenium, for automatization of sending commands to a site, through JAVA files. On this site, I need to make a date query. I did so to test: element =…
-
3
votes1
answer248
viewsSearch files from a directory
I have a small application that requires a search engine capable of listing the files that contain a term informed by the user. The first functionality of the program, which is responsible for…
-
3
votes1
answer263
viewsPreparedstatement select with like 'something%' in Java Swing
how to perform the survey LIKE 'c%' with PreparedStatement? I have the following code: PreparedStatement pstm; ResultSet rs; public void pesquisarAdministrador(){ String sql = "SELECT…
javaasked 9 years, 5 months ago Hebert Lima 987 -
3
votes1
answer8135
viewsWays to get bank values with Resultset
Ways to get values from the Java database (JDBC). public static Connection getConnection(){ /* 1. Faz a conexao com a base de dados */ /* 2. Retorna qual banco ira trabalhar */ Connection…
-
3
votes1
answer176
viewsWhy does my Drivermanager return null Pointer?
Postgresql 9.4 I execute my class Noticias(). Within the method public static void main() class Noticias() a method is called getConexao(); When I execute pagecontroller?=p=noticias in the browser…
-
3
votes1
answer888
viewsHow to open a JSP within a JSP through a Servlet?
I am using a Script but I am not using Servlet to do the desired action within my page index.jsp, the goal is not to use this Script below to open a JSP file inside my home page index.jsp.…
-
3
votes1
answer152
viewsMy List is not updated correctly with database data
I have a dataTable and a button that selects the object in each line of the dataTable. When I click on that one button Dialog is opened with some data and a Send button, when I click this send the…
-
3
votes2
answers454
viewsHide screen options if user does not have permission
I’m having a hard time in a web application I’m creating here, I’m using spring security to control access, session and login, with backend java with restful and frontend with primefaces. I wonder…
-
3
votes1
answer2865
viewsDoubt in the implementation of the deep search in Graphs
I’m studying for a proof of algorithms and I ended up finding some problems to implement the DFS(Depht-First Search/deep search) using data structure Stack. static void…
-
3
votes1
answer143
viewsHow to not include Finally and still close IO Streams, Connections, Statements, and other Resources?
We know the need to close resources (files, connections, also called Resources) consumed in Java, such as OutputStream and InputStream. When we don’t close them, we create performance problems and…
-
3
votes1
answer1658
viewsChain list ordering
I am doing a job that I need to create a chained list and order it in ascending order, performing my tests I realized that I am losing the reference to a node, the problem may be logical but I am…
-
3
votes1
answer1298
viewsIs there a way to create a repository on Github with an already developed project?
My problem is that I have a project on Github and this project is being developed by me and two others. But suddenly, I really don’t know what happened, my project that was all organized, stopped…
-
3
votes2
answers325
viewsByte validation through an image bit array
I am trying to validate an incoming image in an FTP folder. The images start with the bytes "FFD8" and end with the sequence "FFD9" so that there is the possibility to perform the check. I’m getting…
-
3
votes1
answer1027
viewsFill select return ZIP code web service
I am using the example of the site viacep for when the user enters the zip code is filled in the other data of the address, however I would like the state through a select to be filled…
-
3
votes1
answer84
viewsAndroid Sharedpreferences with Radiobutton
I have two Radiobutton, I want to select one of them, close the app and when open load the last selection. Can you help me? I can’t find a clear tutorial explained. Thank you.
-
3
votes1
answer230
viewsProblem switching from Controller to Model
I’m making a code where it involves MVC. To get past the View to the Controller I’m not having problems, but when will I pass the Controller to the Model I can’t do it, the variable is imported, but…
-
3
votes1
answer144
viewsHow to save String[] in Mysql
Hello, I’d like to save one String[] in Mysql, but I don’t know the type of datatype that saves String[], and what method I use to store this information.…
-
3
votes2
answers1845
viewsHow to recover the return result of a routine from within a Thread?
I need to run a routine within a Thread, and get the return of this method. My code is like this. class Main { public static void main(String[] args) { String resultado = ""; Thread t = new Thread()…
-
3
votes2
answers2045
viewsPostgresql Hibernate Id Generation Strategy
I have a system in JEE7 with Hibernate and Postgresql database, the tables are with auto ID generation by Hibernate: @GeneratedValue(strategy = GenerationType.AUTO) private Integer id; What happens…
-
3
votes1
answer456
viewsWhat better way to make a scattering table
I have to implement a hash table, also known as a scattering table, however my inexperience with this data structure can cause many collisions in my implementation. I would like to know what…
javaasked 8 years, 6 months ago 1fabiopereira 403 -
3
votes3
answers107
viewsDoubt about class inheritance in Java
I have the following code one ebook who inherits the class Livro (superclass). However, I can’t create a new ebook and set in name, when I put the main method (main) makes a mistake. Class Autor:…
-
3
votes2
answers159
viewsDouble wrapper initialization with int does not compile
I want to understand why this boot doesn’t work: (1): Double d = 10; // Não funciona I understand that Double is a wrapper, the compiler should convert this line to: (2): Double d =…
-
3
votes1
answer122
viewsError using Random in JAVA
When I run this code: public class main { static boolean terminar = false; public static void main(String[] args) { long init = System.currentTimeMillis(); BruteForce(true, true, "a123", 10, 10000);…
-
3
votes1
answer27947
viewsFormat CPF or CNPJ field using Regex
I would like a regular expression (REGEX) to format the CPF or CNPJ field This is the code I’ve come up with so far: String cpf ="09551130401"; cpf =…
-
3
votes1
answer119
views@Requiredrole with Basecertloginmodule
My system authenticates the client (it’s a web service) through the BaseCertLoginModule, a class of Jboss based on the Jaas specification. In fact my project extends this class, and this extension…
-
3
votes2
answers677
views -
3
votes2
answers2015
viewsSimple equation of division in java
Good afternoon, I am beginner in java and need to do the following calculation in the language For example: (8/7) *100 = 114% (4/7)*100 = 57,14% (90/112)*100 = 80,35% But the way I’m developing it…
javaasked 8 years, 5 months ago Vinicius Leonardo 233 -
3
votes0
answers98
viewsInvalid icc profile: Duplicate Sequence Numbers
By calling ImageIO.read from the attached image, error occurs Invalid icc profile: Duplicate Sequence Numbers. Very simple code just doing: File file = new File("C:\\temp\\imagem_java_teste.jpg");…
-
3
votes2
answers409
viewsHow to avoid Noclassdeffounderror?
I am developing a project that has many classes, and many files. java, and from time to time, from time to time, this problem happens, randomly. Let’s say: A class that I already used, is working…
javaasked 8 years, 5 months ago Thomas Braz Pinto 313 -
3
votes1
answer183
viewsHow to bring the content of a postgis query to a JSP page?
I have postgis with a database that I downloaded from ibge and I need to make a javaweb application that reads the name of a municipality and brings back the data in svg format and displays the…
-
3
votes1
answer202
viewsExplanation about tags of Android components
I’m developing a app for Android. I found some tutorials to help me in the development but found some tags that I did not understand their proper explanations and when I should use each of them. Are…
-
3
votes0
answers33
viewsNamespace function beyond C#grouping
Hello I was here thinking a little bit and I came up with a little doubt regarding the use of namespace in C#, it would have some function other than the grouping of "similar objects" ? And in a…
-
3
votes2
answers366
viewsConvert Spring XML declaration to Java code
Can someone help me convert the Spring XML code that is just below into a Java code? <bean id="templateEngine" class="org.thymeleaf.spring3.SpringTemplateEngine"> <property…
-
3
votes1
answer738
viewsHow to get quantity of items from an Arraylist?
I’m trying to count how many items there are in one ArrayList, I already have something ready: private int quantidadeN = listaNotificacaos.size(); It should store the quantity within the variable…