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
-
2
votes1
answer608
viewsConvert date from one format to another
I’m making an application for Android that uses the Apoid API of NASA. To do this, the user enters a date, and when clicking the button, a photo of the galaxy referring to the date typed appears.…
-
2
votes1
answer27
viewsDoubt regarding Textwatcher - Android
all right? I’m having trouble with the Textwatcher. Like, I created two "plaintext" that I named "et_texto1" and "et_texto2", when I write something in "et_texto1" it has to appear the word…
-
2
votes1
answer278
viewsCheck if a date is before or after other dates
I am using Java 7 and need to check if a date of birth is before or after certain dates. I’m doing like this: String str1 ="31/12/1960"; Date date1 = new SimpleDateFormat("dd/MM/yyyy").parse(str1);…
-
2
votes1
answer50
viewsFileinputstream class read() method not finding end of file
This program aims to copy the contents of the text file origin.txt and paste it into the file destiny.txt, each space read in the source file, a hyphen must be pasted in the target file. The noose…
-
2
votes2
answers290
viewsWhen printing an array elements are not shown
I am trying to solve a problem where I have to read the lines of a file . txt and separate the numbers of this line and save in a vector. public static void main(String[] args) throws IOException {…
-
2
votes1
answer43
viewsVector error - Arrayindexoutofboundsexception error?
Guys I’m trying to solve this exercise Develop a program to receive the name of a student with their respective 2 grades, then calculate the student’s average and present at the end the calculated…
-
2
votes0
answers628
viewsHow to configure VS Code to run JAVA programs with MAVEN passing parameters?
I have a code with no main method. The project is executed using the following command: $mvn clean install -Dparam1="folder" -Dparam2="path" In Eclipse or Intellij, I just need to create a Maven…
-
2
votes2
answers188
viewsHow to compare 3 variables?
I want to make an algorithm that calculates which of the 3 triangles has the largest perimeter, but my logic is not working. import entities.Triangle; import java.util.Locale; import…
javaasked 4 years, 1 month ago Vitor Dias Alves 21 -
2
votes0
answers96
views -
2
votes1
answer61
viewsCan application with separate frontend be considered monolithic?
I researched a lot but I could not solve this doubt I had when studying on monolithic applications, when backend and front are isolated. I have an X application that the frontend and backend are…
-
2
votes3
answers105
viewsHow to access item in Arraylist
I created a ArrayList for a purchasing system each object is a Item(product), which has the nome, quantidade and preço. However I am willing to make the sum of all prices of all objects that are…
-
2
votes0
answers30
viewsJAX-RS Controllers or Resources compared to Spring MVC
I came from Spring and I’m having a hard time understanding how JAX-RS works in a Java EE application. I have an application running on a Wildfly application server. I created a class to use JAX-RS…
-
2
votes1
answer78
viewsPost-increment, pre-increment and its precedence
In both cases following the precedence of the above table would look like this: Case 1 int x = 3; int y = ++x * 5 / x-- + --x; Based on the table of precedence the post-anointing would not come…
-
2
votes2
answers54
viewsMy while isn’t stopping when the condition is true.. I type "VITOR" but can’t exit the WHILE
import java.util.Scanner; public class RepeticaoWhile { public static void main(String[] args) { String nome; System.out.println("Digite o nome VITOR…
-
2
votes1
answer35
viewsSplitting always 0 even with variables having values. Bug List/Arraylist
I’m training statistics so I started doing a little program to calculate the percentile. The problem/bug occurs during division always returning 0 even with variables having values. public static…
javaasked 3 years, 10 months ago Arthur Santiago 23 -
2
votes2
answers69
viewsHow to apply a condition if all values in a list are equal Java
I have a list of People and I want to know how to know to know if all these objects are equal, Independent of any matricula, userPadrao, business rule, etc... this snippet is from Controller…
javaasked 3 years, 10 months ago Douglas Souza 21 -
2
votes1
answer58
viewsGet date from a string
I am trying to create a regular expression that returns some dates contained in strings. The formats are: dd/MM/yyyy dd-MM-yyyy dd/MM dd-MM Ex: public static void main(String[] args) { final String…
-
2
votes1
answer59
viewsError handling is not occurring
In the code below I treated the error only that after treating it still appears the quantity name (I sent the photo below to facilitate understanding). How do I make him not show the quantity name?…
-
2
votes1
answer26
viewsAccess method of type String with Reflection
I have the following class of Enum: public enum Teste { TESTE( 101, "Teste" ), MUNDO( 601, "Mundo" ); private final String descricao; private final int codigo; Teste( int codigo, String descricao )…
-
2
votes2
answers138
viewsLargest and smallest value of each row of the two-dimensional array
I’m trying to get the lowest and highest value of each line in a two-dimensional array with java, but I’m getting the incorrect values. Follows the code: int[][] arrayValues = { { 21, 33, 70, 16,…
-
2
votes0
answers42
viewsWhy should we use method Resferences instead of both?
When passing functions as argument to high-order functions, we can usually use two different Java 8 mechanisms+: 1. Lambas: var averageLength = stringList.stream() .filter(s -> s != null)…
javaasked 3 years, 9 months ago Anthony Accioly 20,516 -
2
votes1
answer57
viewsJava 8 SE: Finally block of a method is running before entering the method
On page 359 of the Book: Java - How to Program - 10th Edition. Deitel explains the treatment of Java exceptions. It exemplifies the question with the following code: public class UsingExceptions {…
-
2
votes0
answers27
viewsHow can I set 10 items per listview?
Hello, I would like to know how I can show 10 items per page in listview? Adapter: ThreadsAdapter(@NonNull Context context, int resource, @NonNull List<MessageThread> objects, ThreadsActivity…
-
2
votes0
answers27
viewsInterconnection of tables in Mysql in Java program
Good afternoon ladies and gentlemen, I am developing a project for study with 2 tables and these tables need to be connected in a certain value. In my package DAO, have 2 classes Stockpile and…
-
2
votes0
answers34
viewsAnonymous class receiving a value through a function
Guys, here’s the thing, I just came across a situation that I didn’t quite understand how it works. Some objects such as the components in the Java Swing, or any type of frameworks objects that have…
-
2
votes1
answer93
viewsIs it possible to pass an Enum value on your call?
I created in Java a enum for mass measurement units and need the user to pass a value when using it. For example: enum Weight { KILOGRAMS, POUNDS; private float value; Weight(float value) {…
-
2
votes2
answers63
viewsHow to use split() inside a Java loop?
Good evening, I have been learning Java for a while and wanted to know how I could read a text file that has one or two numbers in a maximum of 10 lines. Something like the files below:…
-
2
votes1
answer42
viewsReceive response Okhttp KOTLIN
I am trying to process the data received from an external API. I have two files, one responsible for making the request, and the main one to call the function, but I can’t pass the data return to…
-
2
votes1
answer32
viewsInitialization of variables in Java
Good night Folks! I’m learning java, and if you can help me with that question,... I saw it in a course that I’m doing, in a book that I’m reading, and on websites where I researched this assuming…
java variables typing initialization programming-principlesasked 3 years, 3 months ago Tarcio Vinicius Nieri 73 -
1
votes4
answers1069
viewsSelect and drag Swing component
I made an application that draws rectangles, dots, straights, etc. I wanted when the user clicked with the mouse on top of a drawn polygon, selected the polygon and dragged to where he wants on the…
-
1
votes5
answers4549
viewsHow to pick up images on the internet through Java?
I am very beginner in Java and need to get some images from the internet to insert in my project (there are 5 images). Follow example links: www.tempoagr/tempo/Irati/temp1…
-
1
votes1
answer286
viewsHow to detect collisions using Slick2d?
I would like to know how I can detect collisions between objects using Slick,have some useful example? I’m making a simple little game where 2 squares are moving on the screen and if the character…
-
1
votes3
answers300
viewsAndroid Development Profile (Profile)
I was taking a look here and I still can’t find out if there is a way, I believe you also go through this. When we are developing an application that uses some service, we have somewhere in our code…
-
1
votes2
answers1222
viewsHow to pass the application context to the Adapter by reading Json using Asynctask?
private class GetEmpresas extends AsyncTask<Void, Void, Void> { ... @Override protected Void doInBackground(Void... arg0) { // Creating service handler class instance ServiceHandler sh = new…
-
1
votes2
answers1602
viewsSub report does not appear when running from within the system
Already search in various places, sites and the like and do not find a way the sub report appears when running the program. Follow the codes, if you need anything else, let me know. Leading <?xml…
-
1
votes1
answer693
viewsClient REST process JSON replay without knowing domain objects
I am making a Restfull server with Spring MVC, the controller only returns JSON, until ai blz, would my client know nothing of the domain classes and still process the requests? I was thinking of…
-
1
votes2
answers1054
viewsKeeping an item from a selected Listview when pressed
I’m developing a listview, and I need to leave a selected item when I click, and then take the position of that item, in order to do the inversion of two items, which is up with what is down for…
-
1
votes3
answers364
viewsHow to get the class name where a bean will be injected?
I am configuring two Beans in the file beans.xml to inject Loggers into my classes. <bean id="loggerFactory" class="company.LoggerFactory" /> <bean id="logger"…
-
1
votes1
answer39
viewsHow to turn an Ipath into Path
I’m having second thoughts on how to get one Path through the Ipath, I have a variable of the type Ipath but I have a method that requires a Path, I tried to do a cast but I was unsuccessful,…
-
1
votes1
answer6165
viewsHow to create a . jar file appropriately?
I, who am totally new to Java, am trying to compile a "Hello, World!" project. I followed a few steps of this topic Stack Overflow in English. I followed all the steps, but when I open my jar, it’s…
-
1
votes4
answers775
viewsStatic service class in web application
I have a class to generate report and another to check e-mail in an application, should leave it as static? The email class is to check the email in a certain period or when the user requests.…
-
1
votes1
answer1290
viewsConversion of ASCII code to characters does not work
First of all, I’m new to developing Android. I would like to know why my application hangs when I try to convert ASCII code to characters. private String crip(String str, String psw) { int code = 0;…
-
1
votes1
answer783
viewsDelete log files with a date later than a week using log4j
In my application I use the log4j library to generate the logs of the whole system. It is working correctly, I use the following settings: Direct log messages to a log file…
-
1
votes2
answers569
viewsHide and show the header of a listview when scrolled
I’m developing a app for Android using Android Studio, and want a listview with header where the header is hidden when the list is scrolled down, and it appears when scrolled up regardless of the…
-
1
votes1
answer360
viewsRepeat the animated background
I made an app with an animated background, here’s the code: Main layout: <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:tools="http://schemas.android.com/tools"…
-
1
votes2
answers241
viewsHow to know if the keyboard (Keyboard) is visible?
Is there any method that tells me when the keyboard appears and disappears?
-
1
votes1
answer37
viewsHow to get an Iresource from an Icompilationunit
I am making a plugin in eclipse and when I select a java class in Package Explorer I end up receiving an object of the type Icompilationunit, but I need a Iresource, what can be done ?…
-
1
votes1
answer233
viewsBroadcastreceiver - how to register for addProximityAlert method
The snippet below has the mission to give a warning to the user if he entered an area of terrain that is a circle around the given geographical coordinates: double mLatitude=35.41; double…
-
1
votes1
answer2276
viewsRead multiple objects in Java serialized file
I have a file Produtos.ser where several objects of the type were recorded Objeto. In the code method below, I wish to retrieve all objects from the file and store in an Arraylist list. However, it…
-
1
votes4
answers3813
viewsHow to check if one string is contained in another?
I have several strings in one ArrayList. I would like to know how to return a string from that list that contains another one that was passed. For example, if I pass one String "Bean", want to…