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
-
4
votes1
answer781
viewsWhat is the purpose of the Ternal lateinit?
I converted to the Kotlin a simple Fragment with any button. In the alternation, it basically looked like this: Java private Button btn; Kotlin internal lateinit var btn: Button What is the purpose…
-
4
votes1
answer368
viewsDifference between methods to close Jframe and Jdialog after keyboard event
I need to implement in a desktop application built using swing, a way for the JFrame main close the application when user click on ESC, and the JDialogs daughters of this JFrame, close only…
-
4
votes1
answer727
viewsGenerate pdf in java
Good afternoon, I would like a help regarding generating a pdf report in java. Well I am using the first faces to export this report. I created the first line with the fields as you can see in the…
-
4
votes2
answers4120
viewsQuestion about reading txt files on Android?
On the basis of that question by stackoverflow in the reply is suggested this code try { AssetManager assetManager = getResources().getAssets(); InputStream inputStream =…
-
4
votes1
answer167
viewsAdd elements to a List<? extends Number>
Why it is not possible to add elements to a list of type List<? extends Number>? for example : public class GenClass{ public static void main(String args[]){ List<? extends Number>…
-
4
votes3
answers1175
viewsUsing Double in the compareTo method
I’m having a doubt. I have several methods of comparison, however, one of the attributes used to make the comparison is double. Then an error occurs: Cannot invoke compareTo(double) on the Primitive…
-
4
votes1
answer2391
viewsWhat is Entity Manager?
What is the Java Entity Manager? Attending a class on java the teacher mentioned that the method find() of Entity manager and that this method, when searching for a record in the database stores the…
-
4
votes2
answers858
viewsOperator in java
I am learning Java and came across the need of the operator in. For example: I have a vector (v = {1,2,3,4,6}) and I want to see if 5 is in this vector (there is in this case). In python would be v…
-
4
votes1
answer824
viewsHow to return 2 objects at the same time in a Java method?
public class Equacao2Grau { int a, b, c; public int CalculoDelta(){ return (int) (Math.pow(b, 2) - 4*a*c); } public int FormulaQuadratica(){ int x1…
-
4
votes2
answers1719
viewsApplication boot with Windows
I have a Java desktop application, and I need it to be always started together with Windows (as a Windows service for example). This application should be running in the background and always be…
javaasked 8 years, 8 months ago Van Oliveira 91 -
4
votes1
answer113
viewsDoubts about formatting hexadecimal numbers in java for use in MD5
I would like to know why the author of the article put this part: senha = String.format("%1$032X", i); I was curious how he got this string: "%1$032X" Follow the full code: import…
-
4
votes3
answers404
viewsHow do you test something "unstoppable"?
Testing certain components of a system is simple if that component does not have very relevant dependencies, such as a class like this: public class Data { private final String _field; public…
-
4
votes1
answer377
viewsIs it possible to select all Edittext text when in focus?
I have a EditText and when I use: editText.requestFocus(); I’d like you to select the whole text, it’s possible?
-
4
votes2
answers643
viewsHow to send an error message to view
I am a little lost here, I would like to put a parameter in the view to inform the user that his password is wrong, expired etc. the problem that spring-security identifies.…
-
4
votes1
answer944
viewsHow to pass values by reference in Java?
Gentlemen, one of the methods of the class Array has the method sort. The method sort works like this: Arrays.sort(vetor); The vector itself is changed, I searched in many places and from what I…
-
4
votes1
answer1193
viewsCreate class inheritance
I am studying object-oriented Java programming and need to perform the following exercise: Implement the class Funcionario and the class Gerente. Create the class Assistente, which is also a…
-
4
votes2
answers622
viewsHow to rotate an arrow inside a circle using Java2d?
Previously, I asked "How to draw an arrow using Java2d?" and now with the arrow drawn correctly and positioned within my circle, I would like to make the arrow rotate within the circle so that the…
-
4
votes2
answers1210
views -
4
votes4
answers569
viewsIn Object Orientation, does an inheritance violate encapsulation?
According to the book Design Standards written by Erich Gamma, Richard Helm, Ralph Johnson and John Vlissides, make a statement: "...inheritance violates the encapsulation." Below is the paragraph…
-
4
votes1
answer655
viewsHow to associate/open mp3 files in raw folder?
I’m in trouble with songs, whenever I add some music and I will run some error code, whenever I click on the music in the raw folder appears a text , in tutorials that I saw the person clicks on the…
-
4
votes1
answer102
viewsPicking Strings from other Activitys
How do I pick a String, or more, from another Activity, and then use it in another Activity, someone there can tell me?
-
4
votes2
answers351
viewsJoptionpane in the foreground
I have an app that uses one JOptionPane to show an error message, however I would like the JOptionPane always appeared in the foreground. JOptionPane.showMessageDialog(null, "Usuário ou senha…
-
4
votes1
answer1406
viewsDoubt about System.currentTimeMillis()
I was discussing with a friend now little about the origin of the number that results from this method. Where does it come from? It has been counted since when? It reset?
-
4
votes1
answer149
viewsCustomers do not communicate in the same multiplayer game in Java
I’m trying to make a simple tank multiplayer game by implementing chat. The game and the chat are all ok! However, I can’t get 2 customers to view the same object Arena. In this case, each customer…
-
4
votes1
answer305
viewsRowfilter.regexFilter does not filter Date type columns in Jtable
I have a JTable with a TableModel customized, and I’m trying to run a search field using JTextField. However, columns of the type Date and my class Cadastrante are not researched. In my TableModel,…
-
4
votes2
answers9616
viewsRead input data to EOF in URI Online Judge
Hello, I’m trying to solve the following problem below: However, I am having trouble putting this EOF condition in java. Here on stack I found attempts solutions, but they are related to using…
javaasked 8 years, 7 months ago Filipi Maciel 395 -
4
votes1
answer3440
viewsHow to override equals method?
I am trying to overwrite the equals method for instead of validating if an entire object is equal to the other just check if a value this object is the same as the other. Cenário Real: Student…
-
4
votes1
answer150
viewsDoes Xamarin generate Java source code?
I read that with Xamarin it is possible to program in C# for example, and generate a native application Android and IOS. After programming in C#, does it generate sources in Java? I can after making…
-
4
votes2
answers2263
viewsModeling for comprehensive entity registration
I am creating a registration modeling in the most comprehensive way possible. Entities are Person, Natural Person, Legal Entity, Supplier and Customer Below the entity person. I add the person the…
-
4
votes3
answers294
viewsTransform Set<Integer> into Set<String>
I need to store a Set<Integer> within a sharedpreferences, however it only accepts Set<String>, has how to make this conversion ? Set<Integer> checados = group.getCheckedIds();…
-
4
votes2
answers2008
viewsSave multiple instances of a class to a List in Java
I have a college job that I need to create several instances of an object Pessoa and save these instances in a listing to show the user when needed (this will work as a database). Since we haven’t…
-
4
votes1
answer126
viewsError in JSF converter
I’m having trouble converting JSF, always returns null. Convert Project: @FacesConverter("projetoConverter") public class ProjetoConverter implements Converter { @Override public Object…
-
4
votes1
answer630
viewsHow to use a counter inside a Hashmap?
It is possible to do this? public static void main(String[] args) { Scanner in = new Scanner (System.in); Map <String,Integer> mapa = new HashMap <String,Integer>(); mapa.put("45 - Jose"…
-
4
votes1
answer1410
viewsHow do I run an algorithm when the user stops touching the screen?
I would like, when the user presses the screen, to open a horizontal menu with 4 options where the option to which he drops his finger on top will be selected. The pressing event I already know.…
-
4
votes1
answer420
viewsMulti Thread Socket Server and its Clients talking to each other
I have a question that is killing me and I would like to share with you, maybe someone has the answer or a way forward to address this doubt. I have good experience with Web/Desktop development,…
-
4
votes1
answer577
viewsjava.lang.Numberformatexception: Invalid double: ""
While running my app appears error: java.lang.NumberFormatException: Invalid double: "" I don’t know what to do. The error happens when I leave a blank value, for example, the app makes the sum of 2…
-
4
votes1
answer155
viewsArray and type being created
In Java, when I have the following instruction: int[] ns = new int[5]; the following doubts arise: An object of what type is created? For each value in an index, I call it an instance?…
-
4
votes1
answer435
viewsPOST Spring Data REST does not work with relationships
I’m with a project using Spring Boot and Spring Data Rest to serve a Rest API. When I’m serving an entity without relationships, it works smoothly. The problem is when I use an entity with…
-
4
votes1
answer365
viewsProblems with connection to the MS Acces bank
Staff I developed a web application whose database is MS Access, well, when the user logs in I send the data by ajax to the java class to do the login and password validation, the problem is that…
-
4
votes1
answer1008
viewsStackoverflow in bidirectional relationship at JPA
I’m facing this problem with a bi-directional relationship, when I put in a question to create an answer it makes persistence, even then beauty, but if I try to get a get or even in the answer the…
-
4
votes2
answers430
viewsCut bidirectional relationship looping
I am with a Spring project, using JPA and liquibase, I have a bi-directional relationship between two entities, I wonder if anyone has a solution to the problem of infinite referencing between the…
-
4
votes1
answer774
viewsHow to create a method in a Jbuttons Array that changes the color of jButton with Actionperformed?
I am doing a project that requires the creation of a pencil tool that will paint a group of jButtons positioned in gridLayout (10x10) as if they were pixels. I created a method called 'colorButton'…
-
4
votes1
answer329
viewsCreate Splashscreen to show file copy progress
I’m trying to create a splashscreen because when my application is open I perform some time-consuming actions, such as: Copy files Run a . exe My Main is like this: import…
-
4
votes1
answer524
viewsHibernate is not creating or updating BD tables
I have the classes Beans.xml <?xml version="1.0" encoding="UTF-8"?> <beans xmlns="http://xmlns.jcp.org/xml/ns/javaee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"…
-
4
votes2
answers1128
viewsWhat does an abstract class type variable mean?
Studying Pattern design I saw something that I didn’t understand very well what it means, when we have a variable of the type of an abstract class what it means exactly? Example: ClasseAbstrata…
-
4
votes2
answers1052
viewsCannot pass a null Grantedauthority Collection Spring Security
I am developing a web application with Spring Boot, and I am trying to implement authentication using Spring Security. I am following the tutorial from Michelli, but I’m making the following…
-
4
votes2
answers73
viewsCreating an array from two
I have the situation where I need to build in java a arrayC[] from a arrayA[4] and a arrayB[7], where the arrayC[] should present in order the arrayA[4] and then the arrayB[7]: for example:…
-
4
votes2
answers498
viewsBlocked installation when debugging app by Android Studio
When trying to debug or install an application I am developing, the following message appears on the device where the APK is being installed. Blocked installation. This app contains code created…
-
4
votes1
answer130
viewsDetached Exception in associative table
I am finding the following problem when making a certain registration: Exception in thread "main" javax.persistence.PersistenceException: org.hibernate.PersistentObjectException: detached entity…
-
4
votes1
answer328
viewsApp restarts when it changes orientation (rotated)?
I made this in my app: onCreate: @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); ... instances: @Override protected void onSaveInstanceState(Bundle…