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
votes3
answers3871
viewsHow to put hint on a spinner?
I have a Spinner, where the user should select his gender: So far everything works well, but I need to leave a hint written the word sex in the spinner component, as well as in the image below: Code…
-
3
votes1
answer342
viewsChange Httpparams code to httpurlconnection
I have a code that connects json to a mysql database, but Httpparams is obsolete in the version of java I’m using, so I’d like to know how to do it or how best to put new parameters and maintain…
-
3
votes1
answer3270
viewsStep by level in binary tree
Description of the problem I need to solve: "A level walk on a tree, first list the root, then all nodes that are at level 1 then all nodes of level 2, etc. Write a procedure to list the nodes of a…
-
3
votes1
answer424
viewsRun Java class by passing parameters to Scanner
Bestamos creating a programming championship in Java and we would like the students to make an algorithm that reads from a scanner and calculates a certain mathematical logic and returns in the…
-
3
votes1
answer293
views"Too Many Connections" Java + Msql
Hello, I have following problem, I have a function that searches the database and returns an object. I have a "for" function that calls this method almost 300 times, due to this amount of calls…
-
3
votes2
answers2281
viewsSave a foreign key entity with Hibernate 4
I’m starting to study Hibernate and I’d like to know what the method of saving an entity with a foreign key looks like. The following is an example of two entities: Pupil: @Entity(name = "aluno")…
-
3
votes1
answer280
viewsBackslash in Regular Expression
was studying java and the course instructor left a challenge to validate an email using regular expressions. I searched the regex API documentation...for the Pattern part.. The problem is that I…
-
3
votes1
answer222
viewsPage Controller Pattern vs Front Controller
What is Page Controller? What is Front Controller? From what I read, page controller means a controller that is embedded in the html/jsf page facelet. However in the Front Controller the controller…
-
3
votes2
answers3493
viewsDifference between primitive type and object in Java
In Java, we have so-called primitive types and so-called objects. What’s the difference between the two?
-
3
votes1
answer1109
viewsSplit(), using | (pipe) as separator, does not correctly separate the text
I’m developing an app for android and now did the part of Httpurlconnection, I put everything right, I pointed out url and took a test with System.out.printl(line) and on the console prints my…
-
3
votes1
answer198
viewsDo not repeat letters (char) in an ASCII matrix
You had to create a 5x5 array by printing random characters from the ASCII table. public class ExercicioClass01g { static Scanner ler = new Scanner(System.in); public static char mat[][] = new…
-
3
votes1
answer2951
viewsERROR: android.view.Inflateexception: Binary XML file line #0: Error inflating class Textview
When using the LayoutInflater with this XML gives the following error: <?xml version="1.0" encoding="utf-8"?> <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"…
-
3
votes2
answers104
viewsJava2d time-based drive
I’m trying to move an object using Java2d but I’m having some problems, I have following method: public void logics() throws Exception{ before = System.nanoTime(); loop.logics(diff); after =…
-
3
votes1
answer561
viewsRead txt file whenever there are changes
I have a problem in a project I’m doing, I need to do a program that reads a txt file and imports it to Mysql, I was able to do this part. But now I need this program to read this txt file whenever…
-
3
votes1
answer421
viewsHow do I access the contents of a Jtextfield?
In a java project no connection to Database where we have only the layers Model, View and Controller, what would be the most appropriate way to catch a String which is contained in a JTextField of a…
-
3
votes2
answers324
viewsWhen to call super.nameAll when override(override) a method?
In one class we have several methods superimposed with the @Override, and in some, for example onPreExecute of an extended class of AsyncTask, comes with the super.onPreExecute(). @Override…
-
3
votes1
answer562
viewsHow to optimize Hibernate query
I am developing a system in JAVA and use Hibernante to generate my queries with the bank. I need to solve the following problem: I have some classes that belong to an entity and I need to execute a…
-
3
votes1
answer85
viewsSmsmanager on Dual Sim phones
I have been researching the subject, but I have not yet seen any definitive solution to the problem. Well, my application does send SMS from Smsmanager however, it does not ask which chip to use…
-
3
votes2
answers340
viewsDifference between Java Arrays
What is the problem in Android of not setting the size of the array? I’ve seen in several places that it should be started with a default value. What’s the internal difference of doing this:…
-
3
votes1
answer429
viewsMore than one list in the same loop
I can put more than one list on it loop? for example, you can put more than one variable in a for: for (int a, b; a<10 b<20; a++ b++) { ....... } So I wanted to put more than one list on it…
-
3
votes1
answer38
viewsI don’t understand this form of static variable declaration
Why this statement seems neither method nor attribute? static{ } this is the original code private static MessageDigest md5 = null; static { try { md5 = MessageDigest.getInstance("MD5"); } catch…
-
3
votes2
answers282
viewsLike timing an Interstitial ad?
How to Time an Interstitial Ad? Example:. @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); interstitialAd = new InterstitialAd(Main.this);…
-
3
votes1
answer45
viewsHow to get the edge of the line drawn with Graphics in Java straight?
I made a program that traces lines on the screen, but the line is very deformed (image 2) in certain links. I wanted to know if there is a way to leave straight (image 1) the edge of the line in…
-
3
votes1
answer157
viewsJavadb generating sequence of ids with 3 digits
I’m trying to learn Hibernate with JPA, I did a test to record in the Javadb database and realized that the id autoincrement instead of generating an initial sequence of a digit (1,2,3,4...) is…
javaasked 8 years, 5 months ago felipe.rce 1,969 -
3
votes1
answer155
viewsUse a Threadpool or just start a new Thread?
Let’s say the software every time creates a new Runnable to perform a basic function at each cycle, at the end of a running day I would have a few hundred Threads of this function created and…
-
3
votes0
answers137
viewsUpload excel (.xlsx) with jsp
I am developing an application to submit Excel files to an application. However if I try to submit a file .txt,works properly if I send a file .xlsx the file copied to the server directory appears…
-
3
votes1
answer84
viewsHow to rescue a variable from an Actor in Libgdx?
I have the following Actor: public class Carta extends Actor { Sprite sprite; public static int val, pos, peso; Texture texture; public Carta(int valor, int posicao) { val = valor; pos = posicao;…
-
3
votes2
answers294
viewsDo threads share the same memory address as an object method?
I searched here in the O.R.. I have a program in Java that makes use of Threads. public class Objeto { int i; public Objeto() { i = 0; } public void Foo() { i++; System.out.println("Aqui " + i); } }…
-
3
votes1
answer180
viewsHow to add elements of two streams in java?
Hello, I would like to make a function that sums the elements of two Streams and returns a Stream with the results, in a "functional" way without using third party libraries. For example:…
-
3
votes2
answers677
viewsJava regex help - comma-separated sequence of numbers
I’m breaking my head to put together a regular expression that validates String: /aluno/1/Teste dos Testes/1,2,3 String reg = "/aluno/[0-9]+/[^0-9]+/......." I’m having trouble validating last field…
-
3
votes1
answer222
viewsHow to handle multiple inputs with the same name in Java?
How do I manipulate in the back-end using multiple Java input's with the same name? For example: <input type='text' name='telefone' ><br> <input type='text' name='telefone'…
-
3
votes1
answer88
viewsError returning Hashmap to Javascript
When returning the hashmap to javascript I got the following error: The Resource identified by this request is only capable of generating Sponses with Characteristics not acceptable According to the…
-
3
votes2
answers85
viewsClass declaration in Java
I can declare more than one class in the same Java file, and if this is possible, it is the most correct way to program in this language?
-
3
votes1
answer301
viewsException divided by zero in Java
Why this generates an Arithmeticexception / by zero: for (int i = 1; i <= 5; i++) { System.out.println(i); int a = i / 0; System.out.println(a); } And that’s not (print "Infinity")? for (int i =…
-
3
votes1
answer1045
viewsURI Online Judge - 1168 - Java
I am trying to solve the 1168 URI problem. However, I am not getting the number of Leds needed to mount a number. Specifically, my variable is valorLed is always resulting in zero. Can you help me?…
-
3
votes0
answers522
viewsProblems with Cellular Electronic Account Files(Febraban)
It is not enough to be neither a technical doubt, but if someone has some light of the layout used by the VIVO Company in the archives. On the website of Febraban itself has a layout, but it is not…
-
3
votes1
answer994
viewsDifference between type inheritance and implementation inheritance
My teacher passed a booklet on Object Oriented Data Structure with Java and in the booklet there is an excerpt (without deepening) that says the following: "Interface promotes heritage of type and…
-
3
votes1
answer1765
viewsHow to change the text color of a column of a Jtable
I have a form for payment of installments, and this form has a table where I show both the installments paid and those that should still be paid. To popular this JTable, I make a query in the…
-
3
votes0
answers156
viewsHow to implement Flyway in a Javaee Maven project with Hibernate, vRaptor and JPA?
In a project Maven, JPA, with Hibernate and vRaptor integrated, how to implement easily and effectively, the Flyway? Implementing this, my bank will update how it was in developing the <property…
-
3
votes1
answer573
viewsError generating report with Jasper Reports
I’m trying to generate a report with Jasper Reports + JSF and I’m having the following exception: net.sf.jasperreports.engine.Jrexception: Invalid page index range : 0 - -1 of 0 at…
-
3
votes1
answer201
viewsError accessing dao class by test class
I have the following error, when accessing a dao class of a test class: java.lang.Nullpointerexception This is the controller method: @Post("/consultar_lancamento/{codLancamento}") public int…
-
3
votes1
answer178
viewsIllegalityxception when reopening jInternalFrame several times
I am with an application that is validating when the window JInternalFrame is open or closed, but if the window is opened and closed a few times in a row, the console shows an error and does not…
-
3
votes2
answers452
viewsProblem with Entitymanager and JPA
I have a problem here that says the entitymanager is closed...I took a look at the net to follow the same model, but here’s wrong... this is my entitymanager method private EntityManager…
-
3
votes2
answers567
viewsConstructor with a String and a String array is not working
I created these lines of code in a Java exercise ... public class Pizza { ... public Pizza (String nomeDestaPizza, String[] arrayIngredientes) { ... } } public static void main(String[] args) { ...…
-
3
votes1
answer109
viewsOpen a directory
I’m developing an application that when I click on a button it exports my entire database to an excel file, this file gets inside a folder created by the application itself, this folder created gets…
-
3
votes1
answer408
viewsSearch in associative table
How can I do an associative table search ? There are two entities, Pessoa and Time. Where I came from the Personal association_time that has id_person and id_time. My goal is to list all the id_time…
-
3
votes1
answer40
viewsHow to limit Drag and Drop to certain views only?
I wonder if I can control what goes into my layout (DROP) Because of the image view below I wish only "imgu" could enter my layout, the rest not: findViewById(R.id.imga).setOnLongClickListener(new…
-
3
votes1
answer125
viewsActionlistener does not identify the recovered button
My goal is to click the button Andar and then select on the board which direction the character will be moved to, as shown in the image: My button Andar has a ActionListener and is treated as…
-
3
votes1
answer514
views"toString()" returning Null when it should not
I have the class Aluno. public class Aluno { private String nome; @Override public String toString() { return this.nome; } //metodos getters e setters } Class Vetor public class Vetor { private…
-
3
votes1
answer3486
viewsUse the same jFormattedTextField for CPF and CNPJ mask
I wonder if it’s possible in one JFormattedTextField, toggle mask for CPF and CNPJ. When I wear the mask of JFormattedTextField the value is already static, and if put to the CPF, It will not fit…