Forum: Java 1 Hour Ago |
| Replies: 4 Views: 91 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 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 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 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 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 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 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 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 I think well-formed just means it is correct in its syntax etc. |
Forum: Java 13 Days Ago |
| Replies: 3 Views: 133 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 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 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 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 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 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 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 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 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 |
Forum: Java 22 Days Ago |
| Replies: 4 Views: 154 Where are the declarations of dob and telnumber (the instance variables, not the parameters)? |
Forum: Java 24 Days Ago |
| Replies: 1 Views: 140 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 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 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 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 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 str txtfNum1,txtfNum2,lblAnswer;
did you mean String ? |
Forum: Java 28 Days Ago |
| Replies: 2 Views: 394 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 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 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 |
Forum: Java 31 Days Ago |
| Replies: 6 Views: 206 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 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 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 Views: 221 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 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 Views: 205 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 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 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 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 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... |