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
-
7
votes1
answer5553
viewsjava.lang.Illegalargumentexception error in Hibernate when working with Enum
Take a look at the error message: jun 02, 2015 5:23:57 PM com.sun.faces.lifecycle.ApplyRequestValuesPhase execute ADVERTÊNCIA: /WEB-INF/template/pedidos/CapaPedido.xhtml @29,99…
-
7
votes2
answers2804
viewsGenerate Ireport / Jasper Report containing 2 pages (with 3 columns each) on the same sheet in landscape mode
I’m making a report for a client and I’m not getting it assembled according to your need. What it needs is to generate a PDF of A4 sheet in landscape mode, containing each sheet two pages (odd and…
-
7
votes2
answers1375
viewsWhat’s the difference between On heap and Off Heap in Java - JVM Memory
I would like an explanation determining the characteristics of On heap and Off heap Memory in Java. We know that Thread Stacks, the code of our application and the Buffers NIO are all allocated Off…
-
7
votes1
answer2555
viewsStream() and parallelStreams()
I saw that the performance using Amble and streams is much better than using repeat loops, so I try to use as much as possible. My question is when should I wear Streams or Parallelstreams? How does…
-
7
votes2
answers145
viewsCAST: difference between "(String) Arg" and "String.class.cast(Arg)"
I wonder if there’s a difference between: String a = (String) arg; and the cast class: String a = String.class.cast(arg); I once heard that using the cast static class is more performatic, this is…
-
7
votes2
answers212
viewsWhy Arraylist instead of Stack in the implementation of the Memento standard?
As you all know, the Memento pattern is the pattern that saves different states of objects and then retrieves them. The intention is not to retrieve the "last" to enter and then remove it? This is a…
-
7
votes1
answer120
viewsDoubt with Servlet
Hello, I have a question with Servlet’s. Picture the picture: raiz / / formulario.jsp / Servlet / retornos / retorno.jsp The form sends to Servlet the data by post or get! After this submission,…
-
7
votes3
answers1559
viewsMap show current location
I would like to know how to make the map show the current location of the user. I created this code that apparently was working, only sometimes it fails to catch the location and application of the…
-
7
votes1
answer366
viewsHow to fill an ontology from Java?
I am working with ontologies, and have an OWL file in which my ontology is already all defined, classes, properties Object, among others. I use Protegé 4.1 to fill these policies, creating the…
-
7
votes3
answers22225
viewsHow to compile a. java file using the Ubuntu terminal
I am a beginner user and I need to compile a. java file using the Ubuntu terminal, how to proceed?
-
7
votes1
answer1440
viewsWhat is Spring MVC?
I am developing a web java project and am using the MVC (Model-view-controller),which is a standard software architecture (Pattern design) and know that its function is to separate the…
-
7
votes4
answers957
viewsIntercept Exception
I am using Demoiselle in my application, but it has not been behaving very well in one aspect. In an association between two or more entities, deleting an exception is made. With the exception…
-
7
votes1
answer3295
viewsHow to make my program default to open a file type?
I have a Java application that is very simple, represents a form and, based on what is typed in your JTextField, a file called "formulario.uniXml" is created. I set the extension to this name…
-
7
votes2
answers13793
viewsBlock android rotation
I developed an android app but I need it to just stand up can not lie down... What would be the best way to block the rotation ? Thank you
-
7
votes2
answers1363
viewsWhat is the relationship between JPA and ORM?
I wanted to know the relationship between JPA and ORM because I was in doubt, if both ,.
-
7
votes2
answers2360
viewsFill Jcombobox with an object
I would like a help to fill one JComboBox with a class. In this class, return two parameters: Id and Desc. Category class I need to show in combo: private int Id_categoria; private String…
-
7
votes1
answer751
viewsIs it possible to add Origin in the Header of a redirect according to the HTTP protocol?
I am implementing an application where I need to perform a redirect from one server to another and am encountering problems. While performing a redirect, receive the following error message:…
-
7
votes3
answers1117
viewsHow to use Gesturedetector?
I would like a practical example for this method, because I want you to detect left motion run a command and if you go right run another command. Searching the net I found this code seems to be…
-
7
votes3
answers1081
viewsSort chained list with O(n*log(n) method)
I need to sort a chained list (own implementation, without using Java API) with a sorting method that has O(n*log(n) complexity. Researching methods that satisfy the condition found the quicksort,…
-
7
votes2
answers238
viewsDoubt with recursiveness
I took a table test but the results will never come 0 because I subtract 1 of n but then adds the result with n. The result of this question was 36 and I don’t understand why. public class…
-
7
votes2
answers477
viewsAlternative to Scanner for Data Entry
In java, when we’re learning to capture data input, usually by text mode, we’re told to use the class Scanner. Is there any alternative to Scanner to capture data input by text mode? If so, how does…
-
7
votes3
answers1072
viewsWhat is and what is the function of . (dot) in POO?
A long time ago a teacher defined and explained the function of . in POO (Java class). With time I ended up forgetting, but I found it quite interesting, often we think is just a "point", however,…
-
7
votes2
answers692
viewsWhat is the purpose of the super command when used in the parameter declaration of a method?
In Java the command super has the function of calling the superclass constructor. However, in the method declaration forEach() class ArrayList it is used in a different way than usual, see the…
-
7
votes4
answers1015
viewsProblem with pennies when using the Biginteger type
I’m having a problem adding up pennies. Informo 1200, returns 1.200,00 instead of 12,00. Code: formatar_data(1200); private int formatar_data(int inteiro){ BigInteger valor = new…
-
7
votes2
answers736
viewsWhat is the advantage of using Junit to test methods in a class?
I created an application that is basically a class that tests if the methods of another class are returning the expected values. My teacher asked me to remake this class as a Junit test case. I did…
-
7
votes1
answer2978
viewsPagination with large amount of data
Thinking about performance, what is the best way to paginate a large amount of data? I’m currently wearing a List<Produtos>, keeping around 500 products in it, and using subList(min,max),…
-
7
votes2
answers6247
viewsHow to get the current date/time, independent of the device?
Well, I know that when you create an object like Date: new Date(), the time and date of the device is returned, so if I arrive at settings and change these values, then the time returned will be…
-
7
votes1
answer239
viewsWhat is the difference between method annotation and attribute annotation
Guys, I started learning and using the hibernate recently, and while searching for answers to my questions regarding the annotations I have come across following occasions: 1st) The attribute has…
-
7
votes1
answer297
viewsMulti Tenancy with Hibernate update schema
Hello I am with an application that uses multiple databases (multi-tenancy) using Hibernate. I wonder if anyone knows any way Hibernate can update the bank schema. I’ve already set the property…
-
7
votes1
answer236
viewsWhat is the usefulness of the ! operator in Java?
In a if(!aplicaDescontoDe(valor)); in which the method aplicaDescontDe is a boolean, how it works not understood? In that Example: public boolean aplicaDescontoDe(double porcentagem) {…
-
7
votes2
answers329
viewsHow to transform attributes into properties?
In C#, I can avoid using getter and setter, transforming the attributes into properties, as below: public class Pessoa { public int pes_idade { get; set; } public string pes_nome { get; set; } } You…
-
7
votes3
answers1691
viewsButton does not execute the Managedbean method
When I click the change or delete buttons, Managedbean methods are not executed. Anyone have any ideas? Some settings are missing on the buttons? Project: https://github.com/fercosmig/Forum…
-
7
votes3
answers3385
viewsWhat are asynchronous processing and synchronous processing?
I’m having this doubt while I’m studying about the class Handler. In the book it says that when a Thread is being used to perform some asynchronous processing and need to update the graphical…
-
7
votes3
answers1666
viewsIonic is suitable for what types of applications?
The Ionic Framework is indicated for what types of applications? I’ve been doing some research on the plugins of Cordova, seems to give much problem in cross platform development, some plugins do…
-
7
votes2
answers5722
viewsWhat is the difference between Wait() and Sleep()?
The meaning of the two words seems very similar. What’s the difference between wait() and sleep()? When to use each?
-
7
votes2
answers1171
viewsEntitymanager or Session? What to use?
I have worked with projects that used both Session and Entitymanager but it was never clear which one to choose. On what basis they differ in terms of performance and compatibility. Someone can give…
-
7
votes4
answers3293
viewsSeparate String Number Letters
I need to separate the characters of a string into numbers and letters. Ex.: Entree: "A1B2C3D2Z9" Exit: List<Character> numeros = { '1','2', '3' } List<Character> letras = { 'A', 'B',…
-
7
votes3
answers160
viewsCheck if you have more than one character in a String
How can I check how many "@" you have in a string? example: "@Teste @Teste" has 2 @, how can I do this java check?
-
7
votes2
answers820
viewsWhat is type and state inheritance?
Recently in a Java simulation, I came across a question related to inheritance classification, which I had never seen before. Taking the opportunity, I will separate into topics, so that the answer…
-
7
votes2
answers1757
viewsHow to receive a List (Java) in Javascript, using Spring MVC?
I have a web application using the Spring MVC framework. I need to receive a List in a Javascript function, but I don’t know the best way to do this, without getting the code confused. The Processes…
-
7
votes1
answer730
viewsClient-Server Chat application with Sockets does not work
I’m doing a project and I got to the communication part between the server and the client and I couldn’t get the output I wanted (image output). The goal is for the server and client to communicate…
-
7
votes1
answer4407
viewsWhat is the difference between Traffic Light and Monitor?
I have a doubt in the concept of these two structures. What would be the difference between them? Which is faster? And which is easier to use? Could you give me a basic example of each?…
-
7
votes2
answers298
viewsWhat is the difference of use between mouseClicked and actionPerformed?
What is the difference between these two events: mouseClicked() and actionPerformed()? What differs in their execution and when they will be executed?
javaasked 7 years, 5 months ago UzumakiArtanis 9,534 -
7
votes2
answers3006
viewsHow to capture the first letter of a String name and if the letter is 'C' save the name in an array?
I have an algorithm that reads a name of someone and if the name starts with the letter "C" should capture the name and save in the vector. I’ve tried it anyway but I can’t do it. public static void…
-
7
votes1
answer950
viewsVector within vector. What does it do in this context?
Forty students were asked the level of quality of food in the student canteen, on a scale from 0 to 10. ( 1 meaning horrific and 10 meaning excellent). Put the 40 responses into an entire array and…
-
7
votes1
answer649
viewsDo I need to close the connection in each query?
Currently I have a web application that queries multiple databases in the same controller. For each database I request a connection at the server startup and keep them in a static class where the…
-
7
votes1
answer586
viewsDo Java 8 streams and streams bring more benefits than concision?
The only benefits I understand in Amble and streams Java 8 is code saving and, as the case may be, better expressing the author’s intention. That’s all? Is there any example of code that uses one of…
java lambda-expressions java-8 functional-programming streamasked 7 years, 4 months ago Piovezan 15,850 -
7
votes3
answers454
viewsWhy was the parameterized class attribute <T> not instantiated?
I have this class that implements the IDAO interface package DAO; import java.util.ArrayList; public class BdApp<T> implements IDAO<T> { ArrayList<T> lst = new…
-
7
votes2
answers327
views -
7
votes1
answer604
viewsDifferences between listeners and Adapters in swing
When programming java graphical interfaces using swing, we always come across both types, mainly to assign and create events from button actions or other components. Though I’ve been messing around…