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
votes4
answers398
viewsUse of self-reference
About the use of self-reference thiswanted to know what difference it makes: public static class Aluno{ private String nome; public String getNome(){ return nome; } public Aluno(){ this.nome="abc";…
javaasked 7 years, 10 months ago Sergio Souza Novak 513 -
4
votes1
answer83
viewsImplement contact editing after saving to the database
Hello! I’m adapting a aplicativo that manages contacts with interaction banco de dados. In the aplicativo, I am inserting and deleting contacts but I’m having difficulties to implement the método to…
-
4
votes1
answer1544
viewsHow to use the Servlet context Listener to start a Servlet so when the application is loaded?
I have the following declared Servlet on web.xml and would like it to be initialized before any of the other application Serrvlets: <servlet>…
-
4
votes3
answers404
viewsGrab Preview image of a video / listFiles() does not work
I have two problems in a super simple project that I am developing in which I did not find a solution in the Forum nor in Google, the project is a video management. I’ll leave the Github link below…
-
4
votes2
answers980
viewsAnalyze sound waves from an MP3 file and representation
Is there any way, in Java/Android, to open an MP3 or WAV file and from the same get the sound waves constantly ? according to its reproduction ? and power from that constant return make its graphic…
-
4
votes1
answer4499
viewsOpen modal with Javascript to select certificate and send to server
When we enter the page eCAC - Virtual Call Center and we click on Digital Certificate on the right side of the screen a modal is opened to select certain certificate that we configure in the system…
-
4
votes1
answer505
viewsJSF/Hibernate How do I save null to a database field?
I have an application using Primefaces/JPA-Hibernate/Tomcat8, and I need that when a field on the screen is empty, it will record null in the bank (Postgres). I need this because I have some fields…
-
4
votes3
answers122
viewsWhy does the code print 0 instead of 5?
Why does this code print 0 instead of 5? class B { private int b; public int getB() { return b; } public void setB(int b) { b=b; } } class A { public static void main (String[] args) { B b = new…
-
4
votes1
answer482
viewsChange text of a Jtextarea at runtime
Good morning to all, I have a backup routine that should write the result in a JTextArea, at runtime. The copy works, the problem is that the window containing the JTextArea gets stuck and does not…
-
4
votes2
answers335
viewsHow to iterate an attribute with Java Reflection?
In the method below, I use Reflection to set attributes from one class to another, based on mapping via Annotation. How do I map an attribute of a class that is an attribute of another? For example,…
-
4
votes2
answers118
viewsWhy does comparing different objects return true?
First code: Integer i1 = 1234; Integer i2 = 1234; System.out.println(i1 == i2); //false System.out.println(i1.equals(i2)); //true Even though it seems that primitive types are being used, they are…
-
4
votes1
answer533
viewsMethod Invocation may Produce Nullpointerexception
I’m using geocoder to turn the Edit text address into Longitude and Latitude. Then he’s doing it right and saving in the bank the lat and lng, but he gives an Exception that does not cause any…
-
4
votes1
answer336
viewsError when rounding Bigdecimal
I’m performing a calculation with two methods, only since the attributes are of the type double, I’m using the BigDecimal to perform the operation and after that convert to two decimal places only.…
-
4
votes2
answers1471
viewsAllow special characters as Java keyboard input
I am using Scanner to read some keyboard data, however, accents and special characters are not identified. For example: João and Maurício appear with a small square in the accented letter, however,…
-
4
votes2
answers102
viewsDoubts related to recursion
Good afternoon. I am developing recursion methods that work on a binary tree of research, but I am having great difficulties in recursion. For example, the method below should return the tree…
-
4
votes1
answer37
viewsI have a fragment that renders an xml but if there is no record I want it to render another page(xml)
I am new on android and do not know how to do it. Follow a small piece of my code. I will check if there are no records if the list is not empty. If it is empty I need it to render another page of…
-
4
votes1
answer181
viewsDelay of the swing timer.
I’m making a little game that flashes some images in order on the frame, my goal is that they blink in order, but they’re all flashing together: public class Logica { List<Integer> seqAlea =…
-
4
votes1
answer187
viewsRename an element in a Jlist
Greetings, my friends. I have a problem in Java. I am trying to add a "Occurrence" element to a Jlist. This element has 4 elements within it, which I need to maintain. So far so good. However, the…
-
4
votes1
answer250
viewsIs it possible to call a method when the application is closed?
What happens when the user closes the app without calling a preset method in the app, what I mean is when it removes the app from the list of active apps.What happens at this point in time is?…
-
4
votes1
answer4966
viewsGOTO equivalent in Java
Well guys I’d like to know how to do a drop in java? or some way to get back to a certain point in the code, people say that it is dangerous to use this kind of command in java... why?
javaasked 7 years, 8 months ago Jefter Rocha 411 -
4
votes1
answer393
viewsIs it correct to declare GET/SET methods within a STRATEGY class?
I was left with a question when I went to create a project pattern of the type Strategy. It is correct to declare methods GET and SET in a class that implements an interface Strategy? I do not know…
-
4
votes1
answer1360
viewsMVC representation in UML class diagram
I’m building the class diagram of my project and I got a question at a certain point. In the project I create an instance of my Controller class in main and pass the reference (I know that in Java…
-
4
votes2
answers438
viewsList years in Jcombobox dynamically from certain rule
I have an application that lists records in a JTable, and each record has a registration date using Date. On this list, I put one filter per year via JCombobox, where the initial year is what the…
-
4
votes1
answer455
viewsCalculation of the weighted moving average with exponential adjustment
How could I calculate the a in the following java formula: I did the following : Df = Df + a(1 -a) xx i I generalized the formula I just don’t know how to calculate the a, like making a formula…
-
4
votes2
answers1986
viewsJAVA - Draw Polygons (triangles, pentagons)
I was wondering if anyone could help me, I’m doing a project where I have to draw various figures, between them triangles and pentagons, I’ve already got the rectangles working, rectangles: import…
-
4
votes1
answer376
viewsComparison of Bigdecimal result with Float (Java)
I have two formulas implemented, one with the Bigdecimal type and the other with the primitive double type, but the results differ and I am not able to find the solution. Below are the formulas:…
-
4
votes3
answers790
viewsIncrease Precision with Bigdecimal Java
Entrances R = new BigDecimal(2.79E+00); Dxm3d = new BigDecimal(3.99E-04); Wmd = new BigDecimal(2.39E-03); x = new BigDecimal(3.2); t = new BigDecimal(365); Below is the formula BigDecimal…
-
4
votes1
answer1376
viewsHow to use Jprogressbar while method(returns value) performs reading XML files?
I have a little knowledge in Java and I have already researched in the internet about how to use a Jprogressbar while running a method, but I could not get any example that works according to my…
javaasked 8 years, 11 months ago Douglas Ribeiro 69 -
4
votes5
answers1088
viewsDigits in a java string
How do I find out how many digits a java string has ? For example, user entered with "exemplo123", the string has 3 digits. I’m using this function but it’s not working: private static int…
-
4
votes3
answers6177
viewsDate Mask in Edittext
How to put date mask on EditText android, so that stay dd/mm/aaaa ?
-
4
votes1
answer49
viewsExpandablelist Customizable
I’m new to Android, but with an ambitious project. I’m trying to make a ExpandableList customized, with two TextViews on the items and the one on the left needs to have the background changed as per…
-
4
votes1
answer292
viewsStop touch(sound) of notification
I have an Android app that wakes up with the system notification standard ringtone. The problem is that when it clicks on the notification the alarm does not stop. I use a class for notification and…
-
4
votes1
answer341
viewsCheck if String has '+' character
I need to search in a string if it has the + character, like this: teste = teste.replaceAll("+", "e"); but I return this error: java.util.regex.Patternssyntaxexception: Dangling meta Character '+'…
-
4
votes1
answer2157
viewsDifference hashmap and arraylist
Could someone explain to me the difference between HashMapand ArrayList?
-
4
votes1
answer84
viewsthis inside a builder, what does it do?
good , can anyone tell me what this does ? public Tempo (){ this(0,0,0); } public Tempo (int h){ this(h,0,0); } public Tempo ( int h,int m){ this (h,m,0); } public Tempo (int h,int m , int s){…
javaasked 7 years, 5 months ago Pedro Gouveia 505 -
4
votes4
answers20854
viewsHow to order vector in descending order?
How do I place a vector in descending order? public static void vetor() { int[] vet = { 7, 4, 10, 8, 2, 5 }; Arrays.sort(vet); //Comando para colocar em ordem decrescente. for (int i = 0; i <…
-
4
votes2
answers341
viewsDoubt in a Java exercise
I was looking for some Java exercises to train and learn some algorithms when I came across the site exercism. and I decided to do their Java exercises. So far so good, I downloaded their app using…
-
4
votes2
answers1267
viewsDynamically update application
I’m developing a project Java EE where we’ll have a database for each customer, currently use server Wildly. Let’s say we have a server with 30 clients, it would be a server with 30 different…
javaasked 8 years, 10 months ago MauricioGuedes 81 -
4
votes2
answers986
viewsWhat is the purpose of setTag and getTag methods in View?
In the TextView declared this way below, is used the 1 as definition the attribute android:tag. Look at: <TextView android:id="@+id/tvJonSnow" android:layout_width="wrap_content"…
-
4
votes1
answer987
viewsConvert a String Arraylist to a Json
I need to convert one ArrayList of String on a JSON. I have a method in which I get a list of apps installed on the mobile device. This method returns me the data in a String Arraylist. I was able…
-
4
votes1
answer84
viewsJPA does not reflect the changed data in the BD manually
I have a Javafx application with Hibernate (JPA). In this application I update a Tableview with the data I search from BD (Mysql). Every time I click for the system to search in the BD some data, it…
-
4
votes1
answer253
viewsDoes the Netbeans Builder GUI Code affect application performance?
Netbeans has a user interface creation tool using the swing, which greatly facilitates the development of desktop applications, however, the tool seems to create numerous lines of code even for…
-
4
votes1
answer173
viewsInitialization of attributes
Is there any difference between initializing an attribute like this: public class Turma { private List<Aluno> alunos = new ArrayList<Aluno>(); } Or so: public class Turma { private…
-
4
votes2
answers3727
viewsGreater and lesser number
I need to sort three numbers I can’t use for and neither vectors. I know it’s easy but I can’t do it. My problem is, I can’t keep the highest value. public static void main(String[] args) { Scanner…
-
4
votes1
answer1058
viewsAccent problem while consuming Webservice on Windows Server
Correction I have an accentuation problem when consuming Webservice on Windows Server. I have apache-Tomcat-7.0.63 installed on windows server 2008, and as SGB, Postgres 9.4 and with Java 8. The…
-
4
votes1
answer1484
viewsUpdate a Jtable that is in a Jframe from a Jdialog
What I’m doing is a little longer, so I’m going to shorten the problem with a more objective example: I have a registration form and created a modal Jdialog with the fields I want to search. When I…
-
4
votes1
answer243
viewsRemote debugging in isolated environments
I work at a company doing bug fixes. Some clients deploy the system to computers on their internal network, so it is not possible to debug it remotely. Customers' computers usually have Internet…
-
4
votes1
answer1735
viewsProblem retrieving Datasource in Wildfly: javax.naming.Namenotfoundexception
I am trying to establish a connection using Datasource, and is returning the following error: Feb 08, 2016 8:15:03 PM org.xnio.Xnio <clinit> INFO: XNIO version 3.2.2.Final Feb 08, 2016 8:15:03…
-
4
votes2
answers1398
viewsJava to Kotlin conversion
One of the qualities cited about the Kotlin language is the creation of clean code, that is, code that is pleasant to read and that can accomplish its goal without curling. From what I saw, Android…
-
4
votes1
answer2107
viewsQuestions with the Connectionfactory and DAO class
I want to make a crud simple I am basing myself on some ready classes. My doubt follows: public class ConnectionFactory { private String url = "jdbc:postgresql://localhost:5432/aluno"; private…