Most viewed "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
-
56
votes4
answers107040
viewsWhat is the difference between public, default, protected and private modifiers?
What are the differences between modifiers public, default, protected and private when working with inheritance? There are rules of how and when I should use them when I’m working with heritage and…
-
59
votes4
answers106387
viewsHow to compare Strings in Java?
The operator == says that strings are different, they store the same literal value, see the example: public class TesteString { public static void main(String[] args) { String str1 = "teste"; String…
-
38
votes3
answers96047
viewsWhat is the use of a static or final variable in java?
What is the difference of the declaration private static int var_nome for private final int var_nome for private int var_nome? How these statements can influence my algorithm?…
-
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?
-
9
votes7
answers91443
viewsError: Unable to find or load the main class in Java (Eclipse or CMD)?
If you ever came across the error message: Erro: não é possível localizar nem carregar a classe principal you probably won’t be able to run your code in Java. In the eclipse I came across this…
javaasked 9 years, 8 months ago Maicon Herverton 877 -
12
votes4
answers77025
viewsHow to run . jar with prompt?
I’ve managed the jar file for Netbeans, but I’m unable to run the program at the command prompt. What command to run it in Windows environment?
-
20
votes2
answers70450
viewsError trying to run Eclipse: Java was Started but Return Exit code =13
After having the hard drive changed, I downloaded and went to try to run the eclipse and it returned the error: Java was started but return exit code =13 What is causing this error?…
-
22
votes1
answer68862
viewsHow to generate a . apk file in Android Studio?
If it is already generated in which folder it is located?
-
11
votes5
answers61683
viewsUsing line break " n" in Java
What problem can a Java programmer have when using "\n" to jump line? Observing: I’ve used it for N reasons, record a file TXT and others.
-
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.…
-
50
votes4
answers58057
viewsWhat is the purpose of @Override?
I’m having some doubts about @override, read somewhere and remember vaguely on the question of rewriting, but what is it? And what is it for? How does it apply in a code JAVA. Exists in some other…
javaasked 10 years, 10 months ago Rogers Corrêa 2,596 -
7
votes2
answers57495
viewsFormatting a double in java
I would like to know how to keep the variable double with 2 houses after the comma. Below I have an example, when transforming a String in double if it has values after the point is kept the 2…
-
4
votes1
answer57092
viewsHow to resolve java.lang.Nullpointerexception?
I created the class Server! However an Exception of the type is launched java.lang.NullPointerException! I wonder if someone could help me with this problem? The class is as follows: public class…
-
71
votes6
answers56799
viewsWhat is Nullpointerexception and what are its main causes?
What are the exceptions NullPointerException? What are its main causes? What methods/practices can be used to prevent?
-
38
votes3
answers53541
viewsHow does the DAO Standard work?
I researched and read about DAO (Data Access Object Standard), but I’m not getting to understand how it works and how is its structure, it is also responsible for the business rules of an…
-
35
votes2
answers48974
viewsWhat does public Static void main(String[] args) mean?
I want to understand what each item of public static void main(String[] args) in Java and when to use.
javaasked 9 years, 6 months ago Tiago Oliveira de Freitas 1,798 -
9
votes4
answers47343
viewsRemove element from an Arraylist in Java
I’m having trouble removing an element from my Arraylist, someone can help me as? public String remover(Pessoa umaPessoa) { String mensagem = "\n******** Pessoa removida com Sucesso! ********\n";…
-
30
votes1
answer46121
viewsWhat is a DTO?
I’ve been dealing with Java for a little while and I always hear the expression DTO related to pulling something from a bank, but I never really understood what it is. Is it just a name to reference…
-
3
votes3
answers43625
viewsRegular expression that accepts only numbers and/or letters in Java
How to develop a regular expression that allows a string to have only numbers and/or letters in any position and quantities? Examples: to) 00000a b) 000000000A c) AAAAAAAAA0 d) 1AAAAA1113 and)…
-
55
votes2
answers39510
viewsHow to remove accents and other graphic signals from a Java String?
How to remove accents and other graphic signals from a Java String? Ex.: String s = "maçã"; String semAcento = ???; // resultado: "maca"…
-
7
votes2
answers36959
viewsHow to generate an executable program . jar in Netbeans?
I made an application in Java and liked, now I need to get executable to show my colleagues. How do I get the executable?
-
31
votes6
answers36799
viewsHow to read a text file in Java?
I have the file called dados.txt and I want to put it on String. For example: String texto = lerArquivo("conteudo.txt"); Question How to write this method lerArquivo()?…
-
3
votes2
answers35944
viewsTaking time in format: HOUR:MINUTE:SECOND
I currently use this code: // Pega a hora Date hora = new Date(); hora.getTime(); He returns it to me: Thu Aug 28 21:55:42 BRT 2014 I would like a way to get only hour, minute and second. How to do…
-
22
votes4
answers33277
viewsUsing the keywords Throws and Throw
How do I use the words Throws and Throw in a Java code?
-
41
votes5
answers32714
viewsJava Library for Brazilian Electronic Invoice (Nfe)
I’ve been developing an enterprise management system for some time. I need to add to it the electronic invoice issuance functionality in the Brazilian standard. Is there a well tested and preferably…
-
8
votes3
answers31605
viewsCheck if the element exists in Arraylist and, if not, add it
I created a state class with name, acronym and capital and a country with name, capital and states - an Arraylist of the type State. I want to create an input methodState(and status) that before…
-
10
votes3
answers31029
viewsWhat is a Servlet and what is it for?
I’ve heard a lot about the term servlet, however, I still can’t understand. What really is a servlet? What is the point? What is its practical applicability?
-
34
votes3
answers30862
viewsWhen to use Stateful or Stateless
I would like to know the difference and when to use. Stateful Stateless
-
6
votes2
answers30147
viewsJoptionpane, for example?
Well, Joptionpane needs all these complements: JOptionPane.showOptionDialog(parentComponent, message, title, optionType, messageType, icon, options, initialValue); Could you give an example of all…
-
4
votes3
answers29445
viewsHow to check if the String is null or blank in Java / Android
I went through this problem implementing a simple library of database queries sqlite in android and would like to share the solution with the community, I believe it will be useful since I have…
-
10
votes2
answers29411
viewsHow to export a DIV HTML to PDF by rederizing CSS?
Does anyone have a code that can export a DIV to PDF by rendering all the CSS of this DIV? Is it better to do this in the backend (Java) or in the frontend (Javascript)? If anyone can help, thank…
-
16
votes3
answers29267
viewsBarcode Converter - Convert Barcode to Digitized Line
I’m reading the bank note barcode, but found that the barcode does not exactly match (numerically) the digitable line (also called line code, numeric code or IPTE). According to a document from…
-
22
votes1
answer28962
viewsHow to use debug in Eclipse?
I’m having a very annoying problem with a java.lang.Nullpointerexception error and I wonder if with debug it shows which element is null, rather than just which line is the error.
-
10
votes3
answers28595
viewsCalculator with Java Graphical Interface
I started working with the Swing framework, creating a calculator with the JOptionPane, and managed normally. Now I was launched the challenge of inserting buttons +, -, *, and / in the calculator,…
-
37
votes1
answer28542
viewsWhat are the most relevant differences between C# and Java?
I wanted to know the most relevant differences that I should know exist between these two languages. Why am I asking this here? Because normally in my day-to-day when I ask this question, my…
-
11
votes4
answers28007
viewsHow to read CSV files in Java
I am developing a web application, where after the user uploads a CSV file, my java application needs to read this CSV. Preferably separate the data into fields, for example to add these into a…
-
3
votes1
answer27947
viewsFormat CPF or CNPJ field using Regex
I would like a regular expression (REGEX) to format the CPF or CNPJ field This is the code I’ve come up with so far: String cpf ="09551130401"; cpf =…
-
11
votes1
answer27744
viewsConcatenate Strings into Java Loops - Stringbuilder or '+'?
Java allows us to concatenate Strings in Java using only the operator '+' String str = "a" + "b" + "c"; It’s a simple way to do the job, and much less verbose than with Stringbuilder. But in cases…
-
42
votes1
answer27667
viewsWhy and when to use Enum in Java?
Someone who is learning the language, novice or experienced, may never have crossed paths with Java enumerations. I have read several times that they are useful, for example, to implement the…
-
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?…
-
9
votes1
answer27206
viewsDatabase connection - Mysql and Java
I already have a local server on my machine (localhost) with Mysql running normally. From there, I would like to connect my database with Java, but... how do I do that? Is there any Swing component…
-
-1
votes2
answers26904
viewsHow to Export an HTML table to PDF and EXCEL
Good morning guys, someone has to give me a help regarding to export an HTML table to PDF and EXCEL, I better do this in javascript(front end) or java (backend) any hint help! thanks.
-
4
votes5
answers26088
viewsRegistration problem (Column Count doesn’t match value Count at Row 1)
I am having the error "Column Count doesn’t match value Count at Row 1" when I try to register. I already checked my comic book and everything seems to be in order but nothing to solve this mistake.…
-
31
votes3
answers25678
viewsWhat is a Java Bean and what is it for?
I’m starting to read about development java layered, and read something about the bean, an encapsulated class. But I couldn’t find any content that would really explain the purpose and an example.…
-
4
votes2
answers24752
viewsWhen executing "java" command in CMD it is not possible to locate or load the main class
After executing the command javac normally and create the file .class, I try to execute the command java plus it gives this problem of not being able to locate or load the main class. I think it…
-
48
votes3
answers24523
views -
16
votes1
answer24414
viewsWhat is Maven for?
I often find large projects that have the pom.xml file, but I never understood the usefulness of it, I just found out it’s something related to Maven. Finally: What is Maven for? What is the pom.xml…
-
3
votes5
answers23968
viewsHow to get and format current date and time?
I would like to know how to get the current date and time and then format them in JAVA. For example, I have these two values: 23062017 212010 I want to store each value in a variable, and then I…
-
39
votes3
answers23304
viewsWhat is the difference between "passing by value" and "passing by reference"?
I know that in the first the object passed as an argument to a function is copied, and in the second not. I also know that it is extremely unusual in modern languages to pass complex objects by…
-
37
votes5
answers22775
viewsWhat is the best way to iterate objects on a Hashmap?
What is the best way to iterate objects into one HashMap in Java to gain access to the key and value of each entry?