Posts by Bruno Neuman • 559 points
8 posts
-
3
votes2
answers432
viewsQ: Create a set method for different variables
I’m looking to create a Setter for an object Character, where it will modify the attributes String name, int intellect, int strength and int stamina, but what is the best method to do this? public…
-
2
votes1
answer1794
viewsQ: Capturing events on a button
I’m starting in GUI in Java and wanted to understand how it works to capture events on a button, as for example in the code below: Simplegui1.java import javax.swing.*; import java.awt.event.*;…
-
6
votes1
answer1441
viewsQ: Execution flow of a Try/catch/Finally block
How the execution flow works in a block try/catch/finally in the example below? public class ExceptionTest { public static void makeException() throws ExceptionAlpha, ExceptionBeta, ExceptionGamma {…
-
6
votes1
answer1796
viewsQ: Exceptions in Java
I am studying about exceptions in Java and would like to understand better. When declaring an object, if the programmer predicts that a failure may occur in the execution of the method, he will…
-
15
votes1
answer1050
viewsQ: Reserved 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 Bruno Neuman 559 -
2
votes1
answer54
viewsQ: Defining the constructor of an Object
Hello, I’m doing exercises on constructors in Java but I’m having a question. I have two classes Main java. public class Main { public static void main(String[] args) { Duck[] d = new Duck[5]; d[0]…
-
5
votes3
answers456
viewsQ: Infinite object?
I ended up doing something that made me curious: I created a Cao class to follow: public class Cao { String nomeDoCao = null; Cao caes = new Cao(); public void setName(String name) { nomeDoCao =…
-
5
votes2
answers1174
viewsQ: Instantiating an Object with a different reference
I’m learning polymorphism in Java, but I’m having some doubts. public class Animal { int numPatas; public void fazerBarulho() { // Código do Método } public void comportamento() { // Código do…