Posts by Math • 30,313 points
252 posts
-
18
votes1
answer1050
viewsA: Reserved word "this"
this refers to the current object. Always read so it will become clearer to you: this object Example: public class Esse { public static void main(String[] args) { Esse esse1 = new Esse(); Esse esse2…
-
3
votes3
answers2716
viewsA: Is it possible to create a MAP<> within another MAP<>?
Yes, it is possible. To put a value on the map inside the first map, do so: Map<String, Map<String, String>> teste = new HashMap<String, Map<String, String>>();…
-
2
votes1
answer596
viewsQ: Failed to install Olamundo.apk on device 'Emulator-5554': EOF
From time to time when trying to run my application in the emulator I come across the error: [2014-07-23 20:59:09 - Olamundo] Failed to install Olamundo.apk on device 'Emulator-5554': EOF…
-
6
votes3
answers456
viewsA: Infinite object?
This becomes something infinite correct? Yes, you have prompted a new Cao type object at each instance of the Cao class, i.e., recursively you have created new and new Cao objects until the stack…
-
18
votes4
answers3366
viewsA: Are getters and setters an illusion of encapsulation?
At first it may seem that it makes no difference between leaving your attribute public or leaving private with getters and setters without validations, because your access is free for modifications…
-
12
votes6
answers1170
viewsA: Why is it not possible to define an interface with static methods?
Methods in interfaces are implicitly public and abstract. That is, as much as you declare a method like this in your interface: public interface MinhaInterface { void teste(); } Implicitly what…
-
26
votes4
answers67145
viewsA: Composition and aggregation: what are the differences and how to use them?
The difference is only conceptual. Aggregation It is when an object has other objects, it does not depend on those objects to exist. Example: A Drawer may contain Socks, but the Drawer is not made…
-
5
votes1
answer1101
viewsQ: How to make a Listview with components next to the text on each line?
Several current Androids systems have menus like the one in the example below: Notice that anywhere I touch my finger in the blue area under "Access my location" it turns on or off the switch and…
-
4
votes3
answers3004
viewsA: Access data from already instantiated classes
Considering another supposed class called Usandouserinfo.java, which is in the same package as your User_info class, do: public class UsandoUserInfo { public static void main(String[] args) {…
-
5
votes2
answers2013
viewsA: How to pass a JSP file to Servlet?
From what I understand you need to send a file through an input="file" type element and read the contents of it. I will need to do a project like the answer I gave in your other question: The big…
-
14
votes2
answers11031
viewsA: Why can an inner class be Static and an outer class not?
static means that something belongs directly to the class and does not need an instance of that class in order to access it. What can be static: Methods; attributes; and Nested classes. Static…
-
8
votes2
answers11631
viewsA: Subtract JAVA dates from picking the days difference
You can do this account using the classes Datetime and Duration of the Jodatime library. import org.joda.time.DateTime; import org.joda.time.Duration; public class CalculaDiff { public static void…
-
67
votes4
answers58057
viewsA: What is the purpose of @Override?
It is a way to ensure that you are overwriting a method and not creating a new one. Let’s assume you created a class with a print method: public class SuperClasse { public void imprime() {…
-
20
votes2
answers15418
viewsA: Doesn’t Java have multiple inheritance?
In Java it is not possible for a class to inherit multiple classes. The reason for this, imagine that one class inherits two other classes, however these two inherited classes have methods with the…
-
11
votes1
answer536
viewsA: Why do we have to use mplements?
The purpose of implements it is not to make the code cleaner, is just a reserved word that says that your class is implementing an interface, that is, your class is now the type that it implemented,…
-
11
votes2
answers3778
viewsA: Using JSP and JAVA
The middle man is Servlet. First, let’s name things. No project is too small to use the MVC design standard, which is short for Model - View - Controller, and that means your project must have these…
-
4
votes1
answer1642
viewsA: How to rewind the file pointer correctly in Java?
Bufferedreader You can rewind a Bufferedreader through the methods mark(int readAheadLimit) and reset(). It works like this, at a certain point of your reading you mark that position, and when you…
-
1
votes2
answers1063
viewsA: Send CTRL+V via Postmessage
According to the the MSDN website, there is no constant for the alphabetical keys, so use the hexadecimal value directly. In this case, to simulate pressing the V key use the value 0x56.…
-
3
votes2
answers7595
viewsA: List directory and subdirectory files with listFiles
You can browse a directory structure, subdirectories and files with the method: Path walkFileTree(Path start, FileVisitor<? super Path> visitor) You need to specify the initial directory and…
-
1
votes1
answer2768
viewsA: How do I connect a java program with oracle 10g?
You must download the JDBC driver from the following link: Oracle Database 10g Release 2 JDBC Drivers. Include the downloaded jar to your project’s Build Path. Dynamically load the class…
-
15
votes2
answers5743
viewsA: Level of detailing use cases
Do not make CRUD use cases Imagine the following scenario: Can the Customer handle the Remove Order use case when he has never created an order? No, he cannot. Nor can you consult, change or update…
-
7
votes1
answer7351
viewsA: How do I popular a Jtable?
To create and popular a Jtable, you must actually add the data into a Defaulttablemodel and then set it as the table model. I made an example with comments below: JTable table = new JTable();…
-
2
votes1
answer11000
viewsA: Use the R1C1 property
Activecell.Formular1c1 is for you to write to the selected cell. If you do: Range("D7").Select ActiveCell.FormulaR1C1 = "abc" macro selects cell D7 and writes abc in it. In your example you selected…
-
7
votes1
answer1078
viewsA: "No suitable driver found" in Java database connection
You need to load the class with.mysql.jdbc.Driver. Example: public void Conecta(){ //System.setProperty("jdbc.Drivers", Driver); try { Class.forName("com.mysql.jdbc.Driver"); //adicione essa linha…
-
1
votes1
answer99
viewsA: problem of creating android project in netbeans
According to the documentation: To avoid Conflicts with other Developers, you should use Internet Domain Ownership as the Basis for your package Names (in Reverse). For example, Applications…
-
1
votes1
answer460
viewsA: Problems installing jdk7 or 8 on MAC OS 10.6.8 - Snow Leopard
Download the jdk7-7uX-macosx-x64.dmg in part of downloads from the Oracle website. Use the Pacifist to open and install the JDK 7 Update X.pkg which is in the file you downloaded. Original response…
-
15
votes2
answers378
viewsA: Performance in creating strings in Java
The reply from @Qmechanic73 is good, however it raised a question that I just researched to understand. Why in the example a==c and b==c always return false? String a = new String("foo"); String b =…
-
1
votes1
answer1281
viewsA: Create dynamic columns depending on a checkbox - excel 2007
I can do something similar to what you asked, let’s see if you answer. Assuming the following table: +------------+---------+ | Vendedores | Mês-Ano | +------------+---------+ | João | jan/14 |…
-
2
votes2
answers115
viewsA: Removing object from Arraylist, object is still there
You must override the equals method() When you do: coin = new Item(this, 100, 150); you are creating a new object. So, as much as you have another object with identical attributes in heap , they…
-
6
votes2
answers7797
viewsA: Remove duplicate objects from List<Minhaclasse>
You can do one inside the other by going through the list and storing in different variables each object in the list, then you compare the id, if the id is the same and it is not the same object you…
-
223
votes6
answers64346
viewsQ: What is the difference of API, library and Framework?
They seem to me very close terms and eventually I see texts that exchange one for the other, as if in some situations their definitions overlap. What would be the technical definitions to…
-
1
votes1
answer206
viewsA: Align to center div with variable size
Place the automatic margins: .exemplo { min-width:800px; max-width:1400px; margin-left:auto; margin-right:auto; }
-
7
votes2
answers1336
viewsQ: Javafx application does not run on some computers after exported to jar
I developed a Javafx application, created an Ant script through build.fxbuild and ran a jar. The generated jar runs Ok on the computer on my service and on another developer’s computer, however it…
-
2
votes1
answer289
viewsA: Exclusion involving Java and SQL
You must add the parameter and then run your Preparedstatement. String sql = "delete from Cliente where CPF_cliente = ?"; PreparedStatement stmt = con.prepareStatement(sql); stmt.setString(1,…
-
6
votes2
answers2192
viewsA: Decimal places when using Println in Java
You can use the printf() instead of println(). Example: System.out.printf("Area do Tetraedro = %.2f\n", c1.getArea()); Where %.2f that the second argument of the method, i.e., the first after the…
-
3
votes1
answer674
viewsA: How do I get the name of a button in Mouselistener?
You must call the method getSource() in your Mouseevent object, it will return exactly the object that called the method. It is a good idea before assigning this object to a variable to make a check…
-
21
votes3
answers1131
viewsA: String and its efficiency
Both String and Stringbuilder internally work with character array, just look at their class: String.java public final class String implements java.io.Serializable, Comparable<String>,…
-
4
votes1
answer1087
viewsA: Open word file through the . jar
Use the relative path instead of the absolute path to open your . docx File docx = new File("src/Imagens/codigoCalc.docx"); When exporting, make sure that inside your . jar you have the file in the…
-
8
votes3
answers22703
viewsA: When is the use of composite primary key recommended?
In your case I believe your field comentário must have its own id and must have the post_id being used as a foreign key, as in the case of tax bills, since in these cases you are talking about a 1xN…
-
4
votes1
answer2663
viewsA: Search method involving Java and SQL Server
Preparedstatement is a class whose object stores a pre-compiled value of an SQL sentence. One of its utilities is to make searches in a safe way, because the SQL sentence is mounted setting the…
-
9
votes3
answers1131
viewsA: Open/closed principle - how to understand this?
The open/closed principle basically values not spoiling what is already ready. That is, think of your preferred programming language, now suppose you have numerous applications developed in that…
-
2
votes3
answers2826
viewsA: Add image to . jar
Create a . zip file with all your images and add in your Build Path. Right-click your project folder > Build Path > Configure Build Path > Java Build Path > Libraries > Add Jars…
-
9
votes1
answer1565
viewsA: Launch my Windows application in System Tray
Basically what you should do is take the instance of SystemTray of your operating system and add a new object of type TrayIcon customized to it. The TrayIcon is the object you will work upon. After…
-
26
votes3
answers5608
viewsA: What does "immutable" really mean?
The big question that’s confusing to you is about what is an object. Object, physically speaking, it is a space allocated in memory to keep your reference and use it in your code you need a variable…
-
6
votes2
answers7146
viewsA: How to make buttons of various formats in java?
Create a Jlabel and place an image to your liking, the texture you want and the format you want. To simulate the effect of a button override the methods of mousePressed(), mouseReleased() and…
-
2
votes1
answer716
viewsA: How to communicate between classes?
Basically you must import the package from the other class and create an object from it, so you will be able to access your public methods. Assuming your first code has a BorderPane bpPrincipal; be…
-
3
votes1
answer265
viewsA: Difficulty Creating . JAR in Netbeans
According to this bug report from Netbeans itself this is a bug and to fix just upgrade to version 7.4 or more current.…
-
2
votes1
answer1112
viewsA: Set at least one number in Edittext
Test the size of the Edittext content in the Editor which indicates that there has been a change in it, if the content size of your Edittext is greater than zero enable the button, otherwise…
-
2
votes1
answer5391
viewsA: How do I handle Joptionpane.showMessageDialog() options?
You must use showConfirmDialog() since showMessageDialog() returns nothing. The showConfirmDialog() return an int, store it and then compare it with the static constants of the class JOptionPane.…
-
12
votes3
answers7424
viewsA: How to get the last business day of the month?
You can get the last day of the month by adding -1 day to a date representing the first day of the following month. And if you want the last day of the week, just go back to the days until you find…