I just need some help with this program.
The user has to enter in the id,password,the number of max tries & the number of max uses.
And they have to go into a ... |
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(
...
|
Helo, there are 3 files, CustomerClient.java, CustomerServer.java and Customer.java
|
I have a class,
class MyClass {
private int val;
public static final MyClass myObject = new MyClass(1);
MyClass(int a){
...
|
I was doing a project in a Java book and came across this code example. The author of the book said that instead of initializing X and Y in my constructor ... |
I'm learning about constructors.
When I try to compile the following code, I get the error "variable input and shape are not initialized."
Could anyone tell me why and how to solve it?
public ...
|
Or can this just be done for methods/fields/enum constants?
|
|
why cant i use static as a variable modifier in a constructor and would final work for eg construcor eg in my code below i want to initialise the variable times ... |
Could any one explain the advantage of initializing the instance variables inside a constructor, the same thing we can do after the object has been constructed and calling the respective setters ... |
I have a question about using an object as the variable in a constructor. It might be simple but I just really can't think of what to do and my java ... |
Hi, I have question about a compile time error I am getting. I have 2 classes and one is extending the other one. My problem is about the class variables are not getting recognized before I use the "this()" call in a constructor. Can anybody just go through the following? public class MyClass extends MySuperclass{ int p,q; public MyClass() { this(p,q); ... |
As Bear mentioned, writing a program to automate this is probably the way to go. That said, this situation smells a little like a design issue. Is this behavior that all classes share? If so, should it be pulled up into a super or extracted out into it's own class/interface? Also, aren't you going by Machiavelli now? [ July 21, 2008: ... |
class Super { String hello; public Super(String hello) { this.hello = hello; } } class Sub extends Super { String world = "world"; public Sub() { //super(world); // not allowed //super(getString()); // not allowed super(getStaticString()); // allowed } private String getString() { return "world"; } private static String getStaticString() { return "world"; } } |
Now, in this program: public class CSTest implements CharSequence { private StringBuffer s=new StringBuffer(); private int a,b; CSTest(char[] hello){ StringBuffer s=new StringBuffer(); s.append(hello); System.out.println(s+" "+s.length()); } public String toString(){ String xString=new String(s.toString()); return xString; } public int length(){ return s.length(); } public CharSequence subSequence(int a,int b){ return s.subSequence(a,b); } public char charAt(int a){ return s.charAt(a); } public static void main(String[]args){ char[] ... |
For a programming problem, my textbook asks me to create four constructors to represent 4 different ways in which a line in a plane can be specified. Those 4 ways being, by giving a point and the slope, by giving two points, as an equation in slope-intercept form and an equation x = a if the line is vertical. Here is ... |
First, player should not extend team, unless in your model, a player is a special kind of team. As for your question, what's wrong with theloop you have? I might go for an enum rather than simply a String, but looping through the array, creating a player corresponding to each element is perfectly reasonable. Also, Java class names by convention start ... |
I'm working on a "project" where I need to make a class "book" that can store information about a book. It's name, isbn, stock, etc... What is throwing me off a little bit is the author. I'm allowed to enter up to 4 authors per book object. I'm coming at the problem with the assumption, that I should be able to ... |
|
EJP, I dont undearstand what you are trying to say.. Am I doing a guesswork or I need to do some guesswork ? he has mentioned about the java.util.NoSuchElementException. He has provided only a part of the code. Not sure weather he has executed it on his own. Yes, I am tring to guess or probe what he actually looking for ... |