Posts by Math • 30,313 points
252 posts
- 
		25 votes1 answer24414 viewsA: What is Maven for?Maven is a tool developed by Apache, it serves to manage dependencies and automate your builds. Already the pom.xml is the Maven configuration file. Managing the dependencies It is very common to… 
- 
		6 votes1 answer4346 viewsA: How to sort alphabetically and numerically the same list?You are looking for the interface Comparator. This interface gives you the ability to sort a collection in countless different ways. Its advantage over the Comparable is that you do not need to… 
- 
		7 votes3 answers10773 viewsA: Is it possible to use Java pointers?Everything in Java that is not primitive is an object, objects are referenced by reference variables, in a way very similar to C pointers++. That is, what you know as a C++ pointer is known as a… 
- 
		6 votes1 answer13295 viewsA: Send file directly to printer via CMDYou can copy the file to the printer port, like this: copy/b c:\\endereco\\do\\arquivo.ext com3: Assuming the printer is on the COM3 port. The /b serves to indicate that the contents of the file is… 
- 
		108 votes13 answers20263 viewsA: What makes a language to be considered low/high level?The "level" in this context can be understood as the level of detail of the algorithm for it to perform a given task. Making an analogy, consider that you pronounced the following sentence to a… 
- 
		2 votes3 answers500 viewsA: How can I separate a string for example 36529874 from two to two without having any separation carcter for example 36.52.98.74Since it is a String with a fixed size and the output should follow the same pattern, I suggest making it as simple as possible: public class ConverteIMEI { public static void main(String[] args) {… 
- 
		4 votes2 answers1169 viewsA: Doubt - setDefaultCloseOperationYou must override the method windowIconified(), it is invoked whenever the frame is minimized. According to the documentation: Invoked when a window is changed from a normal to a minimized state.… 
- 
		3 votes2 answers801 viewsA: Confirm form closurewhereas the segundo if it is a Jframe within the main Jframe, the right one would be: JFrame segundo = new JFrame(); segundo.setBounds(100, 100, 450, 300); // No método abaixo, diz que não é para… 
- 
		7 votes2 answers3987 viewsA: Double formatting in JavaYou can use Decimalformat: double d = 1243123.1; DecimalFormat df = new DecimalFormat("###,###.00"); System.out.println(df.format(d)); Exit: 1.243.123,10 However Decimalformat uses the properties of… 
- 
		0 votes1 answer676 viewsA: How to maintain the layout of the components created by Windowbuilder in eclipse after compilation?Add the following code inside your main(): try { UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName()); } catch (Throwable e) { e.printStackTrace(); } For example leaving so: public… 
- 
		1 votes1 answer358 viewsA: Button does not appear in windowOne button is on top of the other, because by creating them you have set the same position of them within your Jframe: btnEnviar.setBounds(210 ,110, 170, 70); ... btnLimpar.setBounds(210 ,110, 170,… 
- 
		3 votes2 answers60 viewsA: Innerclass object is created at what point?An Innerclass is created when using the operator new to create an instance of it. For example: public class Principal { public static void main(String[] args) { System.out.println("Comando: new… 
- 
		2 votes4 answers172 viewsA: Rewriting vs Incremental Improvement?The client doesn’t know what a rewrite is. You who have to make the decision and budget a price, then the customer will accept your price or not, what you are doing or failing to do does not matter… 
- 
		25 votes2 answers1393 viewsQ: When should I choose whether or not to use a pointer when creating an object?In C++, I’m used to seeing objects being created through the operator new, which is when the object is referenced by a pointer, thus: MinhaClasse *mc1 = new MinhaClasse(); This form seems to me the… 
- 
		4 votes1 answer1150 viewsA: Create graphical interface using MiglayoutI would make a composition of Layouts, to fix the components in the footer would use Borderlayout and put a panel at PAGE_END. The panel PAGE_END would also be of the Borderlayout type, to fix the… 
- 
		6 votes1 answer2086 views
- 
		59 votes3 answers6039 views
- 
		26 votes3 answers1450 viewsA: Remote control of an Android is technically possible?That sounds more like a job for Mythbusters, but I’ll take my chances on an answer. About the video The video seems to me clearly a montage. It sure is. But until then nothing wrong with that.… 
- 
		3 votes1 answer527 viewsA: java.lang.Nullpointerexception in this codeAs you can see in your stack trace: at PrimosCT.<init>(PrimosCT.java:16) the exception occurs on line 16 of its class PrimosCT, which is the line pp.getButton1().addActionListener(this);. The… 
- 
		2 votes1 answer331 viewsA: Insert component without using setBoundsTo add a Jcombobox without having to define the Bounds just use a Layout Manager which does not require them to be defined. A modern and flexible Layout Manager is the Miglayout, it generates little… 
- 
		5 votes3 answers225 viewsA: Doubt about showing local network IPYou can turn the signposted byte to non-signposted so: ip[i] & 0xFFL; Example: import java.net.InetAddress; import java.net.UnknownHostException; public class IP { public static void… 
- 
		4 votes2 answers588 views
- 
		0 votes1 answer98 viewsA: Vaadin project error in "pom.xml"There is no version 3.0.1 yet, by looking at central repository, I believe you want the version 3.0-alpha-1. Use addiction that way: <dependency> <groupId>javax.servlet</groupId>… 
- 
		4 votes1 answer244 views
- 
		4 votes1 answer83 viewsA: How do I create a String template and whenever the user passes something different report the error?I believe the easiest way to do this is by using Regex. For your case, use the standard "^[a-zA-Z]\\w+". An example code that uses Regex above: import java.util.regex.Matcher; import… 
- 
		4 votes3 answers369 viewsA: Stringbuffer.equals and String.equals difference in JavaThey are different. Implementation of the method equals() in the String.java class: public boolean equals(Object anObject) { if (this == anObject) { return true; } if (anObject instanceof String) {… 
- 
		5 votes1 answer935 viewsA: Join two ArraylistI thought, Instead of having two ArrayListYou only need one, which has the name of the teams. Then you make a permutation 1 to 1, eliminating the cases where the team would face each other, and… 
- 
		4 votes2 answers2276 viewsA: Methods without parameters and with parametersYou hit almost everything, just missed the part of returning a value. A function has the following format: tipoDeRetorno nomeDoMetodo(tipoDoParametro valorDoParametro) { //se o tipoDeRetorno for… 
- 
		5 votes1 answer191 viewsA: Passing data from one txt to another txtYou have two objects referencing the same file, there are no technical problems in it, but the way it is in your code besides unnecessary led you to make a logical mistake because you try to write… 
- 
		15 votes3 answers13854 viewsA: Fill string with zeros on the leftYou can use the Decimalformat class to format its output value. So: //coloque isso no final do seu método converteDecimalParaBinario DecimalFormat df = new DecimalFormat("0000"); return… 
- 
		5 votes1 answer2887 viewsA: How to make an algorithm to turn capital letters into lowercase letters?Portugol has a function that treats this, is the function caracteres_minusculos. From the documentation (which is inside the software itself): Biblioteca Texto funcao cadeia… 
- 
		7 votes1 answer5228 viewsA: Difficulties with rounding using BigdecimalBigdecimal is immutable, so when you call the method setScale() it does not change the variable value bd, he returns the rounded value, however as there is no variable receiving the return value it… 
- 
		5 votes3 answers88 viewsA: Problem receiving random integer values in arrayEclipse does not point out any errors because you are not facing a syntax problem, but a logic problem. Your code even runs, but is stopped during its execution due to the launch of an exception.… 
- 
		6 votes2 answers158 viewsA: Play framework problem with formChange: form(Task.class); To: Form.form(Task.class); Or if you prefer, statically import Form methods like this: import static play.data.Form.*; And keep using the way you did.… 
- 
		21 votes1 answer5399 viewsA: What types of collections and their differences in java?What are the differences between them? First of all it is important to understand that Collection is a term that may be ambiguous, as there are: Collection (or collections in free translation): That… 
- 
		24 votes4 answers1788 viewsA: Are Getters and Setters mandatory or facilitators?The way to make getters or setters is a norm or convention? It is a convention determined by the company itself that maintains the language, Oracle, as you can see in: Javabeans Standard The… 
- 
		19 votes1 answer1099 viewsA: What is the difference between Integer.valueOf() when using String or int parameters?When you do Integer.valueOf(0422), thanks to the prefix 0 at the beginning of the number, the conversion will be made based on the value in the octal basis, and not on the decimal basis. Which is… 
- 
		3 votes2 answers1038 viewsA: Java Timestamp and Mysql TimestampAnswering your question: what is the best way to get a timestamp in Java where you can always reset mileseconds? For cases: System.currentTimeMillis(), Calendar.getInstance(). getTimeInMillis(), new… 
- 
		26 votes1 answer4728 viewsQ: What is technical debt?Technical debt is the sum of some types of backlog in your project that can prevent the evolution of your project. However, this concept is much more comprehensive than that, and I would like to… 
- 
		3 votes1 answer855 viewsA: Compare Local time Joda TimeLocaltime only stores the time information, does not store information of the day, therefore, 20h will always be bigger than 6h. Use Datetime instead, and indicate the full date, with day, month,… 
- 
		2 votes1 answer75 viewsA: Exception occcured while finding Account via IDYou should remove simple quotes from your SQL query: PreparedStatement pStmt = conn.prepareStatement("'select first_name from accout where first_name like ?'"); Should stay: PreparedStatement pStmt… 
- 
		4 votes1 answer213 viewsA: Comparable and Arrays.SortI found three problems in your code, the first is in the Corridax1 class. When you do: while(p[i] != null && i<p.length){ You are likely to receive one ArrayIndexOutOfBoundsException,… 
- 
		17 votes2 answers1978 viewsA: How to use the Java scannerThe @Earendul answer already points out the correct reason why the error occurs, however there is another solution to what it proposes. Explaining the error in my own words, when you use the command… 
- 
		12 votes4 answers2869 viewsA: Is it recommended to use natural primary key?I’d say it’s not recommended. 1. Not everyone has CPF How to do it with foreigners? And minors who do not already have CPF? In these cases they can not create account? 2. CPF generators Imagine that… 
- 
		7 votes3 answers407 viewsA: Generate setters only in class constructor or generate outside constructorYou may well provide no method Setter public for an attribute if you wish, what is not recommended is to leave the attribute as public, because if one day you decide to change it to private and… 
- 
		1 votes2 answers630 viewsA: Add days to a jDateChooserIf you have to use pre-java 8 native libraries you can do so: Calendar c1 = Calendar.getInstance(); //pega data e hora atual java.sql.Date data1 = new java.sql.Date(c1.getTimeInMillis());… 
- 
		1 votes1 answer588 viewsA: Jtable, add multi-lines[Cell span] +Format tableTo hide the vertical lines of your table just use the method setShowVerticalLines() of your Jtable object passing the argument false. tabela.setShowVerticalLines(false); To show the header you must… 
- 
		-4 votes1 answer680 viewsA: Swap application label outside Manifest.xmlUse the following command within some method within your class that extends the main Activity: this.setTitle("Novo título"); 
- 
		8 votes2 answers7414 viewsA: Manipulating String in JavaYou can use Regex. Example: public class TesteRegex { public static void main(String[] args) { String frase = "Várias palavras em uma só String.\n" + "Ignorando pontos; Ponto-e-vírgula; Traços. E… 
- 
		5 votes3 answers8755 viewsA: What is the best way to replace a character in a given String position?There are three classes options to handle Strings: String, Stringbuffer and Stringbuilder. Is used: String: when you don’t want to modify the text too much; Stringbuilder when you want to make…