All Questions
33 questions
0
votes
0
answers
110
views
What am I doing wrong? Setter for private variable does not substitute the value
I have a calculator program and in the main application, it asks the user for a number. Immediately the number should be set to the current value. My current value is a double that lives inside of a &...
1
vote
2
answers
213
views
Private variables inside a parent class
so in the code that my teacher gave me, it has the child call a method that returns a value from a private array.
MY question is, what can a child class see from a parent class? Can it see all ...
-2
votes
2
answers
608
views
Illegal start of expression relating to a Private variable
I was attempting to run a project that my teacher in AP Computer Science supplied us with to check our work. I have been trying for two classes to get the teacher's code to work but to no avail. The ...
1
vote
3
answers
1k
views
grid of buttons and actionlistener
I am using the below code to create a grid of (xSize = 10) by (ySize = 10) JButtons. I am able to make changes to the buttons as long as I do it from within the class that this code is located.
...
0
votes
1
answer
1k
views
Private, Static, and scope of variables in Java
In my Java class, we just learned about scope. And by learned I mean it was briefly mentioned once and never spoken of again. Some questions were posted, and I'm having trouble understanding the ...
0
votes
1
answer
159
views
Change private string when button pressed
all and thanks in advance for replies.
Probably this is a elementary question but I just started learning java.
I want to print the string "username" (which changes after a button is clicked) in ...
0
votes
2
answers
47
views
When referencing a private variable, do you need the this.variableName declaration? [closed]
public class sample {
private int x = 3;
public sample() {}
public sample(int num) {
this();
x = num;
}
public int getX() {
// should I use return this.x; ...
-2
votes
2
answers
105
views
Java: Variable access specifiers
In java, is there a (direct) way to make a variable able to be accessed out of the class but not able to be changed? I have a variable in class A and need it in class B. I can make it public (bad-...
-1
votes
1
answer
41
views
chaing a variable in a public method by a private method java
Is it possible to modify a variable called in a public method by a private method within the public method?
example: // node.left node.right called in constructor so never mind
public boolean ...
2
votes
1
answer
554
views
Can I add more than one field to a single attribute
I was wondering if it's possible to add 2 different attributes to a single attribute. For example I have two attributes:
private var modelYear:int as ModelYear
private var manufacturedCd:String as ...
0
votes
1
answer
76
views
how to access variables from private bodies in java
public void TheBank() {
Scanner Sc = new Scanner(System.in);
System.out.println("Please Enter your Username and Password");
MemoryStorage();// Stores the Username and Password in the system.
...
1
vote
2
answers
71
views
private final int blanki; private final int blankj;
I have this code:
public final class Board {
private final int[][] blocks;
private final int N;
private final int blanki;
private final int blankj;
int i, j;
// construct a ...
0
votes
1
answer
65
views
Designing correctly Java Classes
Lets say I have the classes DrugAmount:
package core;
public abstract class DrugAmount {
boolean drugInMg = false;
boolean drugInMl = false;
double numberofAmpoules = 0.0;
double ...
-2
votes
2
answers
383
views
calling a variable from another class JAVA [closed]
Ok so I made three classes. One is a tester and the other two are blueprint classes.I cannot seem call the private double cart variable from the blueprint class ScanShop to ShoppingCart. I thought ...
-6
votes
1
answer
59
views
Java - Change a variable's value in methods?
I have a boolean variable, which is false. I would like to change that to true.
start.java
class start{
static boolean click;
public static void main(String[] args) {
second class1 = new ...