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
-
6
votes4
answers756
viewsRemove a specific space in a string
I’m having trouble implementing replace in a String in Android Studio. I need to remove a certain blank in the String. Real examples: 8 hrs 2 mins 1 day 2 mins I need the text to look like this:…
-
6
votes0
answers292
viewsSave multiline text in Blob field on Sqlite
I would like a hand in this matter of saving a EditText multiline in a blob field in the Sqlite database, because when I add ContentValue values.put(CriaBanco.OBS, pedido.getObservacao()); in the…
-
6
votes1
answer1486
viewsJfreechart - Chart Customization Problems
I’m developing an application that has a dynamic graphic. I need to change the style of the graphic, but I’m not getting. I need him to have a white background, blue line with square markers and…
-
6
votes1
answer235
viewsPopular via builder with Hibernate
I was reading this article http://blog.caelum.com.br/nao-aprender-oo-getters-e-setters/ and talks about using constructors to popular objects and set aside some setters. How can I use constructors…
-
6
votes2
answers733
viewsEmpty constructor without calling super()
When I do parameterized constructors, I create an empty constructor as well. In the empty constructor, should I always make the call to super()? Why? (Take into account, that my class is just a…
-
6
votes3
answers4966
viewsWhat is the function of the operator "!" (exclamation)?
In this method: public boolean aplicaDescontoDe(double porcentagem) { if(porcentagem > 0.3) { return false; } else { this.valor -= valor * porcentagem; return true; } } What the operator means !…
-
6
votes1
answer106
viewsHow to implement a "one to zero" mapping?
The scenario is as follows: A user may have many or no comments in the newsletters posted on a system - obviously, a comment belongs to a single user. The problem is that Hibernate does not have any…
-
6
votes3
answers175
viewsWhy is my Array item not changed in foreach?
In the call of the method: AlunoPrivado aluno = new AlunoPrivado(); aluno.addCursos("Portugues", "matemática", "história", "física"); boolean result = aluno.changeCurso("Portugues", "ciências");…
-
6
votes2
answers1113
viewsHow to retrieve specific parts/values/os from a string?
I have a ArrayList where I assemble a custom list that is displayed on a ListView. What I need is to pass the value of the selected item to another screen. See below the method that will call the…
-
6
votes1
answer460
viewsHow do I use Scanner to capture keyboard inputs?
I would like to know how to use the Scanner in the java to simulate cin and cout of c++
-
6
votes2
answers1032
viewsGenerate sequential java number with Hibernate
Is there any way using Hibernate generate a custom number to be the identification number of a particular record? I have a system that stores care performed to a patient, every time a new care is…
-
6
votes2
answers7668
viewsWhat does the @Component annotation do?
What Spring actually does when we write it down @Component in a class? How does it work "underneath the scenes"
-
6
votes1
answer1287
viewsHow to resolve Networkonmainthreadexception error?
I have an error in passing the JSON HTTP Client to Android. Follow my JSON code: // constructor public void JSONParser() {} public JSONObject getJSONFromUrl(String url) { // Making HTTP request try…
-
6
votes1
answer2358
viewsHow to send data via POST and recover in a PHP?
How to send the data via POST with send-json method, value 0, following my PHP code: // Recupera os dados $nomeUsuario = $_POST['nome']; $cpfUsuario = $_POST['cpf']; $bairroUsuario =…
-
6
votes1
answer400
viewsHow to Change the VM Heap Space on a Netbeans Platform Project
I’m having the following problem: I have a project from Application of the Netbeans Platform that during the execution the application hangs for good and nothing else responds (one minute of…
-
6
votes2
answers942
viewsProperly configured hibernate does not insert into database
My code does not enter in the database Mysql. It identifies all database, tables and fields, but insertion is not done. Usuariodao.java package br.com.sistec.dao; import org.hibernate.Session;…
-
6
votes1
answer283
views -
6
votes4
answers11643
viewsError while running Hibernate
After catching a little, I’m walking with my project. When running the project, I have the following error: mai 16, 2016 6:41:22 PM org.hibernate.jpa.internal.util.LogHelper…
-
6
votes2
answers963
viewsThe if command in java is not working within a method
I’m a beginner and I’m not getting my code to work as expected with regard to "if/Else". I am using this command within a method and doing as follows: private boolean AutentificaSenha(String s) {…
-
6
votes2
answers15301
viewsDate formatting with Calendar dd/MM/yyyy
I’m having trouble formatting the date to the dd/MM/yyyy format Como aparece: Sat Feb 26 11:38:28 BRT 2015 Como eu quero que apareça: 04-07-2015 Here’s how I show it on the screen…
-
6
votes1
answer86
viewsClass Rectangle, is there a circular class?
I know that Class Rectangle is rectangular shaped for collision of objects, there is a Circular class for this purpose?
-
6
votes1
answer226
viewsWhy a loop FOR faster than 10 FOR together
I made a for alone count up to 1000000 (sending 1 message each loop) and it took 14 seconds. public class main { public static void main(String[] args) throws InterruptedException { long init =…
-
6
votes1
answer383
views -
6
votes1
answer392
viewsHow to calculate point cards
I am developing an application that matches the calculation of total hours worked on points cards, taking into account whether it is night time reduction or not and, if it is, what is the entrance…
-
6
votes3
answers154
viewsDoubt Normalizer + Regex
Could someone explain me the code below? returnStr = Normalizer.normalize(returnStr, Normalizer.Form.NFD) .replaceAll("[^\\p{ASCII}]", ""); returnStr has as initial value a url.…
-
6
votes1
answer201
viewsWhy are you giving this Static variable error?
Why is giving this build error and how can I fix it? Cannot make a Static Reference to the non-static field service…
-
6
votes1
answer441
viewsWhat is the difference between Kotlin data class and Scala case class?
In Scala we have case classes, for example: case class Pessoa(nome: String, sobrenome: String) and in Kotlin we have data classes: data class Pessoa( val nome: String, val sobrenome: String ) What’s…
-
6
votes1
answer882
viewsWhat safe way to check if an object is numerical?
I am implementing some generic functions in a module of my system, and I want to treat in a certain situation if the record is numerical (I do calculations). Then searching some way to do without…
-
6
votes1
answer1544
viewsHow to get the predominant color in an image?
I’m taking a picture of a camera and passing it to a ImagemView and would like to take the predominant color of this image, how could do this on Android? my next classLaiout ( wrote laiout with i…
-
6
votes1
answer51
viewsPOST request on Jetty Client 9.X
I’m using the Jetty Client to request a API Web, until recently everything was ok, but I felt the need to send data via POST. Problem In the documentation of Jetty says that POST request data should…
-
6
votes1
answer71
viewsHow to call an object within the creation of another object
I have a Person class and a Date class, the Person class creates a person the date class creates a date to use as the date of birth in the Person class, how do I create a date without having to use…
-
6
votes2
answers1129
viewsHow do I know if a socket client has disconnected?
I have a server that has a List with all connected clients. Client connects and connection is managed in a unique thread with infinite communication loop. The problem when I drop the client or close…
-
6
votes1
answer593
viewsUsing constructor and using set() for same attributes
I’m studying JPA following the example of uaiContacts. His project is on Github. I took the file example modelContact.java: The class Contact is mapped: public class Contact { @Id @GeneratedValue…
javaasked 9 years, 2 months ago André Nascimento 1,258 -
6
votes2
answers5333
viewsHow to do exponentiation in Java?
I’m trying to make a accrual of compound interest and I have this code that follows until the moment. public class ExDesafio_Aula1 { public static void main(String[]args){ double investimento =…
javaasked 8 years, 3 months ago Tiago Prudente 79 -
6
votes1
answer963
viewsPermutation between two vectors
I’m studying some algorithmic techniques and I came across a problem that I’m stuck with, I need to make all the possibilities of permutation between two vectors. For example: [1,2,3] and [5,6,7]…
javaasked 9 years, 2 months ago Nicolas Bontempo 1,652 -
6
votes1
answer15117
viewsWhat are the differences between Java SE, Java EE and Java ME?
I am studying the Java Language in the course of Information Systems and I realized that the Java language is contained in our day even without realizing it. It is present on both our computers and…
javaasked 8 years, 2 months ago user28366 -
6
votes1
answer106
viewsProblem in creating entity with one-to-one relationship
I created a project for testing, and I’m studying the creation of an entity with relationships, and in that I created two entities with this relationship below: I am managing to create the entities,…
-
6
votes2
answers2168
viewsCompile and run project via command line
I have an Android application developed in Eclipse. I know it is possible to compile and run a project from the console, but I don’t know how to do it. The basic steps to compile a program JAVA is…
-
6
votes3
answers189
viewsHandling items from an Action Bar outside the onCreateOptionsMenu()
I have an item in my Action Bar to display progress (a Progressbar) if a request is occurring. When the request occurs, I must show Progressbar and hide the other items, when the request ends, I…
-
6
votes2
answers2368
viewsHow to use "Biginteger" type to solve this problem?
I’m solving a story-based solution involving the chessboard. See a piece of history: "Then Sessa asked for his payment in grain of wheat as follows: One grain of wheat for the first box, two for the…
javaasked 9 years, 2 months ago André Nascimento 1,258 -
6
votes1
answer266
viewsHow to create a scan sequence in the Postgres database?
I have the following table in the database Postgres: CREATE TABLE customer ( userid character varying(30) NOT NULL, firstname character varying(30) NOT NULL, lastname character varying(30) NOT NULL,…
-
6
votes2
answers249
viewsHow to specify that the constructor type is equal to the one declared in the class?
I created an object that accepts a list of any kind, like this: class Grid<T> { private Integer count; private Integer offset; private Integer limit; private List<T> list; private T…
-
6
votes4
answers364
viewsDifferent methods of creating an object
What is the difference between these two types of creation/instantiation of an object? Usuario usuario = new Usuario(); usuario.listar(); new Usuario().listar();…
-
6
votes1
answer801
viewsAccess database in Openshift
I deployed a project on OpenShift, I used a Cartridge to create a bank Mysql soon after the creation of the bank appear this information: Mysql 5.5 database Added. Please make note of These…
-
6
votes2
answers141
views -
6
votes1
answer873
viewsHow to access data from the innermost "level" of a JSON?
I needed a way to access the innermost "level" of JSON below: (name, value, last query and source) { "status": true, "valores": { "USD": { "nome": "Dólar", "valor": 2.333, "ultima_consulta":…
-
6
votes2
answers704
viewsError replacing occurrence in string using replaceAll
I extract the text from several lines of a PDF, at the beginning of each line I have a configuration of the font size and family used on that line, but then I need to remove this information. First…
-
6
votes3
answers3964
viewsWhat is Threadpool all about?
I’m studying Threads in Java, and came across the following code: ExecutorService threadPool = Executors.newFixedThreadPool(10); for (int i = 0; i < 10; i++) threadPool.submit(new…
-
6
votes1
answer310
viewsIs it possible to have Java SE and Java EE on the same machine?
I can install Java SE and Java EE on the same machine?
-
6
votes2
answers592
viewsBetter performance for few accesses: Hashmap or Treemap?
I use the structure a lot java.util.HashMap<K,V> even for small scopes with few inputs (up to 50). But I’ve been wondering if the structure java.util.TreeMap<K,V> would not be better for…