All Questions
7
questions
1
vote
0
answers
1k
views
How to change variable value in try/catch block [duplicate]
I want to understand how exception handling in Java works and I wrote simple method to set number (by typing it in console; using Scanner).
Method doesn't work properly because it don't see numbers ...
-4
votes
1
answer
5k
views
The final local variable "name" cannot be assigned, since it is defined in an enclosing type
I have this class:
class Tester{
final String rigaFile=riga;
final BufferedReader r=new BufferedReader(reader2);
fr.getList().addListSelectionListener(new ListSelectionListener() {
...
6
votes
2
answers
2k
views
confuse about java thread variable visibility
All example I found which talk about visibility is example with primitive type. What I want to know is: if a object which new in heap, when one thread call its method to change its state, without ...
0
votes
5
answers
2k
views
Why I do not see a static variable in a loop?
I have a static method which sets a variable:
static String[] playersNames;
public static void setParameters(String[] players) {
playersNames = players;
}
Then I have a static block:
static {
...
4
votes
3
answers
8k
views
How can I give a variable to an action listener?
I have a static variable partner in the class. And I want to set a value of these variable whenever a radio button is pressed. This is the code I tried to use:
for (String playerName: players) {
...
3
votes
4
answers
122
views
Why my object sees variables which were not given to it in the constructor?
I have the following code. Which is "correct" and which I do not understand:
private static void updateGUI(final int i, final JLabel label) {
SwingUtilities.invokeLater(
new Runnable() {
...
1
vote
3
answers
9k
views
How to control visibility of variables in Java?
I can imagine 3 type of visibility for variables (but I think there are more):
Variable is used within a method and any changes of the value of this variable are not visible from outside of the ...