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
-
15
votes3
answers15299
viewsAvoiding "!= null" comparison in Java
I work with Java and for countless times I have to take a test object != null on the object before accessing it to avoid Nullpointerexception However, I think this practice ends up making the code…
-
15
votes1
answer1050
viewsReserved word "this"
I would like an explanation with an example if possible on the reserved word this in Java, I didn’t understand very well.
javaasked 10 years, 3 months ago Bruno Neuman 559 -
15
votes2
answers7861
viewsCreating and Validating Java Digital Signature
I’m trying to sign a test NFE with a self-signed digital certificate through the code below. The code at first works, the signature is generated in the file and the validation done through the…
-
15
votes2
answers2992
viewsDecimal places of the float
I am developing an application to control product sales. However, sometimes the added value of reports does not beat decimal places. Gives small differences. How to make the float stop giving these…
-
15
votes3
answers17342
viewsHow to use more than one separation character in the split() method?
I’d like to break a String in various substrings, for this I am using the method split(). Turns out, I’m not sure which characters might be in the variable I use. Exemplifying: String words[] =…
-
15
votes1
answer10089
viewsDifference between Integer.valueOf(String) and Integer.parseint(String)
I need to convert a String in int, and I came across these two options, which have an equal result. Is there any difference between them? Is there any rule/convention that says which to use or is…
-
15
votes4
answers92747
viewsConvert String to whole in Java
How do I capture a String of the user through the Scanner and turn into whole?
-
15
votes1
answer693
viewsHow to discover the mobile operator of Android?
I’m developing an app on Eclipse and I want it to work only on devices of a particular carrier. Any idea how to check the operator?
-
15
votes1
answer318
viewsHow do Proguard remove a class method?
I’m not getting Proguard 4.10 to make a method static turn inline. I can only do that with instance methods. For example, this little bit: public final class Calc { private int x = 0; public int…
-
15
votes5
answers1643
viewsDifference between private and final methods
Studying methods and final classes in Deitel’s book "How to program in Java 6 ed." I came across the following proposition: The declared private methods are implicitly final because it is impossible…
-
15
votes2
answers288
viewsWhere should exceptions be handled to display to the system user?
What is the best place to handle an exception and send a message to the system user in a desktop application? In the controller, in the view or elsewhere?
-
15
votes3
answers16809
viewsHow to generate an executable . jar using Maven?
Is it necessary to make some extra configuration to generate a Maven executable . jar? How have I never used this technology under development desktop I’m a little lost. When I build the project…
-
15
votes0
answers312
viewsCardview does not display JSON information
Guys I’m trying to set some information in a Cardview, where these are obtained from a JSON, however, it does not display, the information search this ok, it returns the values normally but does not…
-
15
votes1
answer357
viewsHow to use Bilge and stream?
I can understand expressions lambdas perfectly in simple cases such as: () -> 42 // Não recebe nada e sempre retorna "42" x -> x*x // Recebe algo e retorna seu quadrado (x,y) -> x + y //…
-
15
votes1
answer59086
viewsJavac is not recognized as an internal or external command
I am trying to compile a java class via command line (cmd), but I cannot, the error shown is: 'java is not recognized as an internal or external command, a operable program, or a batch file.…
-
15
votes1
answer703
views -
15
votes4
answers8013
viewsSoftware to Create Class Diagram
I would like to know what software is used or if there is an online site to create class diagrams, could someone tell me?
-
15
votes2
answers1068
viewsIs there a reason for separating the java and javax packages?
In the java documentation, there are several packages organized within the package java and javax, for the most part. There are even some packages that seem to be duplicated, such as java.sql and…
javaasked 7 years, 8 months ago user28595 -
15
votes2
answers883
viewsWhat is the difference, in practice, between Session and Application?
I’m studying about Tecnologias Web, and during my class there was a topic about concepts involving Session and Application. The technology addressed during the class was C#. I didn’t quite…
-
15
votes3
answers2048
viewsWhat is the function of the toString() method?
What is the function of toString() in Java? Why do we do System.out.println(compObjeto) and in the main() (assuming there is an object for the class comp called compObjeto), he does print of…
-
15
votes3
answers590
viewsDoubt about Inheritance
I have the following case: Avo.: public class Avo { public String quemEuSou(){ return this.getClass().getName(); } } Mae.java: public class Mae extends Avo{ @Override public String quemEuSou() {…
-
15
votes1
answer27253
viewsDifferences @Onetomany, @Manytomany, @Manytoone, @Onetoone
I wanted to build a database with Java Hibernate as below: Doubts: What’s the difference between @OneToMany, @ManyToMany, @ManyToOne, @OneToOne? And what would your statement look like in Java?…
-
15
votes2
answers2907
viewsWhat is Jakarta EE?
Only Javaee nomenclature changed or other significant changes will occur? Will be compatible with Javaee 8-? Javaee and Jakartaee will be maintained by the same community?
-
15
votes1
answer3299
viewsHow to compare two Arraylist and get the values shared by both?
I own two classes, they are: Filtrocity class: public class FiltroCidade { private int idCandidato; private List<String> cidades; public FiltroCidade(){ } public int getIdCandidato() { return…
-
15
votes4
answers5515
viewsDockerize Java Web App: Maven + Tomcat + Docker
I have often seen several tutorials from Docker stop up "ready" services, but I see few related instructions on how to use it within the development flow. Mainly on compiled languages as an example…
-
15
votes1
answer637
viewsHow to find where is the circular reference in GSON?
Imagine that I have these classes: public class A { private B b; } public class B { private A a; } And then I have this: A a = new A(); B b = new B(); a.b = b; b.a = a; Gson gson = new Gson();…
-
15
votes2
answers1034
viewsWhy does the absence of the suffix L cause the long variable to be interpreted as int?
When I use a short number for long, as long long1 = 9797;, the number is accepted even without using the suffix L. However, by placing a higher number - as its minimum and maximum values, for…
-
15
votes1
answer346
viewsWhat is the alternative of 'And' in Portuguese for variable names and methods?
One question that always bothers me when I’m in a Java project where we use Portuguese terms is dealing with method names or variables that represent, somehow, two things and I need to mention both…
-
15
votes2
answers321
viewsHow to emulate the regular expression reset branch in Java
I have this regex: Pattern p = Pattern.compile("(?:([aeiou]+)[0-9]+|([123]+)[a-z]+)\\W+"); Basically, it has the following parts: one or more lower-case vowels ([aeiou]+), followed by one or more…
-
14
votes2
answers1611
viewsHow to obtain form data via "POST"?
Is there any way to receive data from an external form using the method="post" on my jsf page? I can already do that when the data traffic via GET. <f:metadata> <f:viewParam name="dados"…
-
14
votes1
answer1567
viewsUse the same entity in Hibernate to write to two tables
I am using Hibernate to make the persistence in the database, and in a given case, for each update that a certain entity Consultor has, it must update in the main table called TB_Consultorand insert…
-
14
votes3
answers184
viewsDo you have an Eclipse feature that includes "this." before any variable where this is implied?
Every time I see myself putting this. before variables that are class attributes in non-static methods. Eclipse has some option that applies this to all source files?
-
14
votes2
answers2787
viewsWhat is syntax sugar and how does it work?
I have seen in some blogs the use of that term and would like to know: 1) The real meaning of this expression and; 2) How a syntax sugar as the example below in the language java? for (Foo foo :…
-
14
votes3
answers337
viewsDoubt about the responsibility of a get()
It is acceptable to have a method getter that you receive a parameter to be able to have a return variation? Example: getAllNome("M"); <- retorna tudo que for masculino. getAllNome("F"); <-…
-
14
votes1
answer10040
viewsHow to Stop a Thread?
How do I stop a running thread with Java commands?
javaasked 9 years, 10 months ago Leonardo Villela 1,620 -
14
votes5
answers1721
viewsIs it possible to change the type of the variable in Java?
Is it possible to change the type of my variable in Java? For example, I created a variable x, she being a Double: double x; I want to continue using my variable x but she is now a int: int x;…
-
14
votes1
answer1274
viewsSelect Multiple with dynamic operation
I have a select with 4 options. These 4 options are the number of options that will appear in a multiple select. What I want is as soon as the user selects the option of number of frequently asked…
-
14
votes1
answer1047
viewsWhat is the cardinality between a request and the services included in it?
I have the class Solicitacao and the class Servicos. After insertion in the database I intend to recover in a query all the services associated with that request. For example, on a screen I insert…
-
14
votes1
answer276
viewsWhy is using String in a switch block more efficient than in an if-Else block?
According to the java documentation: The Java Compiler generates generally more Efficient bytecode from switch statements that use String Objects than from chained if-then-Else statements. Not to…
-
14
votes3
answers20505
viewsHow to resolve the error - The superclass "javax.servlet.http.Httpservlet" was not found on the Java Build Path
I’m using Eclipse Mars.1 for web development, I received this error when including a file JSP, The superclass "javax.servlet.http.HttpServlet" was not found on the Java Build Path. I also have…
-
14
votes1
answer5215
viewsWhat is JNDI technology?
I am starting studies on corporate applications, and according to my teacher I will need this java technology and I would like to know what exactly is the JNDI.If possible wanted an example of its…
-
14
votes2
answers2102
viewsint and Integer - Java
I’m developing a project in Java and he’s in error, I’ve found it but I don’t understand it. public class Time{ private String nome; private ArrayList<Jogador> jogadores; private Integer gols;…
-
14
votes4
answers1174
viewsHow do I share a Java project with a team?
Does anyone know of a versioner that allows teamwork using Java? For example, a Word Online, where everyone changes the file in real time, and the changes are saved on the server.…
-
14
votes6
answers1655
viewsHeritage and Polymorphism
I have the class Funcionario. private String nome; private int idade; public function vender (Funcionario f) { ... } I have the subclasses Gerente and Professor that inherit (extend) from…
-
14
votes3
answers2393
viewsDivergence in encrypting and decrypting in Java and C# Aes algorithm
I have two projects in Java and another in C# where the two communicate with each other, and one of the functions and encrypt and decrypt the confidential information between them, using aes…
-
14
votes1
answer5228
viewsWhat are the differences between overrideing and overloading in Java?
What are the main differences between overrideing and overloading in Java? What is the relationship between these terms and Polymorphism?
-
14
votes1
answer326
viewsWhat is the difference between >>= and >>>= in Java?
Reading a book about the Java language, I came across some operators I had never noticed before. They are: >>, <<, >>=, <<=, >>>, <<<, >>>= and…
-
14
votes4
answers1204
viewsSpecific use of Try-catch
I am studying Hibernate and with it came some doubts that have come to me before but I did not question in depth. public void salvar(Usuario usuario){ Session sessao = null; Transaction transacao =…
-
14
votes1
answer994
viewsWhat are Raw Types?
Reading and studying a little about Kotlin, I found the following statement: The Raw Types are a big problem, but for reasons of compatibilities they had to be maintained in Java, but Kotlin for…
-
14
votes4
answers1171
viewsWhat is the difference between -= and =-?
In java and other languages I’ve seen in some projects things like: saldo -= 100 and sometimes saldo =- 100 but I could never understand the difference between those two guys, if there’s any…