Search Results

Showing results 1 to 40 of 972
Search took 0.06 seconds.
Search: Posts Made By: JamesCherrill
Forum: Java 1 Hour Ago
Replies: 4
Views: 91
Posted By JamesCherrill
String with a capital S. It's the name of a class - they always begin with a capital. Seems very unlikely that the compiler would change the capitalisation on its own! Duplicate file versions...
Forum: Java 1 Day Ago
Replies: 6
Views: 162
Posted By JamesCherrill
I haven't gone thru all your code, but that looks sensible.
ps You don't need the toString() in a print - the print method calls it automatically. YOu can just say
System.out.println( games.get(i));
Forum: Java 2 Days Ago
Replies: 3
Views: 123
Posted By JamesCherrill
1. char is a numeric type, not some kind of String, so you don't (can't) use .equals(). You can just compare them as numerics (char1 == char2).
2. Wrong. 'A' and 'a' are different chars and are...
Forum: Java 2 Days Ago
Replies: 6
Views: 162
Posted By JamesCherrill
Hi. That other way of doing it is OK too. In my opinion the switch version is easier to understand and maintain, but other people may disagree.
It's not working because in the if statement on line...
Forum: Java 2 Days Ago
Replies: 6
Views: 169
Posted By JamesCherrill
MxDev: I guess English isn't your first language? The verb "demand" is the wrong word to use in this situation, and appears to be very rude. Eg, a master would "demand" something from his servant. ...
Forum: Java 2 Days Ago
Replies: 6
Views: 162
Posted By JamesCherrill
You're very close. Problem is that you parse the input to get an int value 1,2,3 but in the switch you look for values '1', '2', '3'. These values are type char, not int, and are the Unicode/ASCII...
Forum: Java 11 Days Ago
Replies: 6
Views: 276
Posted By JamesCherrill
Put a quick print statement at the start of your dealHand method so you can see if it's the listener call that's failing or the dealHand method itself. I haven't checked all the brackets and...
Forum: Java 13 Days Ago
Replies: 4
Views: 198
Posted By JamesCherrill
addKeyListener is only implemented for user interface components, so sooner or later you will need to use a JFrame or whatever. How is your pacman displayed?
Forum: Java 13 Days Ago
Replies: 3
Views: 200
Posted By JamesCherrill
I think well-formed just means it is correct in its syntax etc.
Forum: Java 13 Days Ago
Replies: 3
Views: 133
Posted By JamesCherrill
Yes, it is a standard problem. The solutions is called a "lock". Each thread has to get a lock on the object before it modifies it, then releases the lock when its finished. If a thread has already...
Forum: Java 14 Days Ago
Replies: 1
Views: 169
Posted By JamesCherrill
http://javabyexample.wisdomplug.com/java-concepts/34-core-java/70-invoking-win32-api-and-activex-components-com-dlls-from-java-ii.html
Forum: Java 14 Days Ago
Replies: 7
Views: 211
Posted By JamesCherrill
No, the two statements are equivalent for both boolean values.
(This is a little obsession of mine. I guess I see
if (booleanExpression == true)
once a week or so, and it always makes me wince).
Forum: Java 15 Days Ago
Replies: 7
Views: 211
Posted By JamesCherrill
These two statements create two constants TRUE and FALSE (Java constants are captialised by convention). These constants are members of the Boolean class, with values true and false respectively....
Forum: Java 15 Days Ago
Replies: 2
Views: 156
Posted By JamesCherrill
pps:
Rather than absolute paths that may not work from one machine to another, you can also get the paths to useful folders in a system-independent way with calls like...
Forum: Java 15 Days Ago
Replies: 2
Views: 156
Posted By JamesCherrill
Make the file name the complete path, startiung with c: or whatever.

ps: Don't forget that \ is the escape character in Java Strings - so to put a \ in the file path you need to code \\
Forum: Java 15 Days Ago
Replies: 4
Views: 180
Posted By JamesCherrill
No. A default constructor just calls the superclasses' no-args constructor. If you want to do any special initialisation you need to write a constructor (which may or may not take arguments)
Forum: Java 15 Days Ago
Replies: 3
Views: 159
Posted By JamesCherrill
The "break" on line 16 is outside any catch, so it terminates the list of catches associated with the previous try. So the catch on line 18 hasn't got a try to match to.
Forum: Java 16 Days Ago
Replies: 4
Views: 180
Posted By JamesCherrill
Not exactly. Constructors can have arguments, or no arguments. If you do not create any constructors, the compiler gives you a "default" constructor which is a no-args constructor that simply calls...
Forum: Java 16 Days Ago
Replies: 3
Views: 112
Posted By JamesCherrill
API doc states:
Forum: Java 22 Days Ago
Replies: 4
Views: 154
Posted By JamesCherrill
Where are the declarations of dob and telnumber (the instance variables, not the parameters)?
Forum: Java 24 Days Ago
Replies: 1
Views: 140
Posted By JamesCherrill
All you are doing here is changing a String within your program. Where does this connect with the actual filesystem?
Forum: Java 25 Days Ago
Replies: 4
Views: 331
Posted By JamesCherrill
It's annoying, but you can't use a primitive type (int/char/boolean etc) with generics.
Forum: Java 26 Days Ago
Replies: 3
Views: 212
Posted By JamesCherrill
Are you sure its "example" not "Example". Java is case-sensitive, and the convention is that class names always begin with a capital letter, so "example" would be a bad example for a class name.
Forum: Java 27 Days Ago
Replies: 7
Views: 181
Posted By JamesCherrill
Maybe you declared, but didn't initialise, your new textfield variables - you need something like

JTextField txtfNum1 = new JTextField ();
Forum: Java 27 Days Ago
Replies: 7
Views: 181
Posted By JamesCherrill
Reading it a agin with my glasses on, you seem to want to use txtfNum1,txtfNum2,lblAnswer as fields on your form, so maybe you should declare them as JTextField
Forum: Java 27 Days Ago
Replies: 7
Views: 181
Posted By JamesCherrill
str txtfNum1,txtfNum2,lblAnswer;

did you mean String ?
Forum: Java 28 Days Ago
Replies: 2
Solved: Jbutton array
Views: 394
Posted By JamesCherrill
quuba's suggestion is OK, it will work, but it ties the external representation of the button text to the internal functions of the code, which is not ideal as a programming technique. (What happens...
Forum: Java 30 Days Ago
Replies: 4
Views: 392
Posted By JamesCherrill
In that case the new element must belong on the end of the list (ie sorts after every existing entry)
Forum: Java 30 Days Ago
Replies: 6
Views: 206
Posted By JamesCherrill
I made no assumption about the data, I was just exploring the logical consequences of the problem statement.
In the case you give, the boolean is false, no further processing is required. You will...
Forum: Java 31 Days Ago
Replies: 6
Views: 206
Posted By JamesCherrill
Did anyone say it was?
Forum: Java 31 Days Ago
Replies: 6
Views: 206
Posted By JamesCherrill
Is this a trick question? If array[i] > array[i-1] for all i, then surely array[i] > array[i-k] for all positive values of k. So you can ignore the inner loop. Or am I missig something?
Forum: Java 31 Days Ago
Replies: 4
Views: 392
Posted By JamesCherrill
Whenever you add an element, iterate thru the existing list elements until you find the right place to insert the new element. That way the list will always be in sorted order
Forum: Java 31 Days Ago
Replies: 6
Views: 310
Posted By JamesCherrill
Maybe the use of <E> in the iterator class is taken as a new declaration of a type, and masks the <E> that is declared for the outer class? If so, maybe you could declare the iterator class as
...
Forum: Java 31 Days Ago
Replies: 3
Solved: Comparator
Views: 221
Posted By JamesCherrill
You use your comparator when you try to sort the array, for example

Arrays.sort(myArrayOfBankCustomers, new NameComparator());

However, you haven't implemented the Comparator interface...
Forum: Java 33 Days Ago
Replies: 7
Views: 245
Posted By JamesCherrill
Assuming these are your classes (not just ones in the Java API) put them all in a jar. Netbeans has a tool for creating one.
Forum: Java 34 Days Ago
Replies: 3
Solved: pass argument
Views: 205
Posted By JamesCherrill
Move the declaration of au outside the action performed method, because now it exists only within that method.
Forum: Java Oct 16th, 2009
Replies: 19
Views: 875
Posted By JamesCherrill
Are you sure?


1. If the second compile always fails you cannot have a second .class file to put into the directory.
2. Thay already had that. What did you change?
3. This is wrong - the...
Forum: Java Oct 16th, 2009
Replies: 15
Views: 358
Posted By JamesCherrill
FYI:
"Boolean.TRUE" is valid Java, but "true" is also valid, and what most people would write.
This code also makes the very common mistake of redundantly using an if test to set a boolean. ...
Forum: Java Oct 16th, 2009
Replies: 19
Views: 875
Posted By JamesCherrill
It's the .class files that need to be in the Assignments dir; the source .java files' locations are irrelevant to this.
The classpath must point to the folder that contains the Assignments folder,...
Forum: Java Oct 16th, 2009
Replies: 2
Views: 241
Posted By JamesCherrill
How about uisng skip(<length of file> - 32) then reading 32 bytes?
ps for reading binary data you should consider FileInputStream rather than FileReader, which is optimised for characters in some...
Showing results 1 to 40 of 972

 


About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC