7,116 Posted Topics
Re: Here's another clue. It should have been a boolean. And calling it "n" was an act of crass stupidity. | |
Re: OO design 101: Underline the most important nouns in the problem description. These are a useful starting pont for a list of main classes. Then collect the data and behaviours associated with each of those to give an external spec. for each class. Review, correct and improve till it looks … | |
Re: Each RGB value is a 32 bit int containing 8 bytes each for R, G, B (and 1 byte for Alpha where appropriate). You need to extract each of the bytes from each int (use bit shifting & masking). | |
Re: [QUOTE=Izzywizz;1075048]... im stucck on the prompting for the file path, any clues?[/QUOTE] [url]http://java.sun.com/docs/books/tutorial/uiswing/components/filechooser.html[/url] | |
Re: Why are you using getName? The internal name isn't usually a user-meaningful thing. Try using getText(). | |
Re: [QUOTE=vara;1074499]i ... if(b==true) ...[/QUOTE] Interesting to see that people are still doing this! Why not go for it and code [B]if (b==true==true==true) [/B] b is a boolean. All you need is [B] if (b)[/B] | |
Re: That's very strange. Do you overide any of the paint methods for any of your graphical objects? What version of Java are you using? | |
Re: You may have a real problem here. I don't think you will find anything faster than a simple array of ints. I tried a quick test, and found execution time ~ 1 sec at 1/100 of your data size, ~1 min at 1/10. I didn't try the full size array, … | |
Re: Neither of these lines gives an error for me (current JDK version / Eclipse). However, if you want to specify a value for these types, using a String rather than a numeric literal seems a little odd. | |
Re: Maybe the way your project was specified doesn't allow this, but... A class Coins as described is just an old-fashioned program with all the data and methods in one place. It's definitely not a good OO design. If the spec allows it, I would start by encapsulating the concept of … | |
Re: the letter cannot be both Q and q, so one or the other conditions must be true, so their OR is always true. | |
Re: dispose() just gets rid of a swing object. If you have two windows and dispose() one of them, the other will still be there. System.exit() terminates the whole program and closes all its windows. | |
Re: If you rhink anyone will study nearly 200 lines of code and data, mostly unformatted and unindented, to find an unspecified error, which may possibly be in a part of the code that you have not posted, you are a great optimist. Re-post, with all the code in code tags, … | |
Re: 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 perhaps??? | |
Re: 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 values for those letters. Just drop the quote marks (ie case 1: … | |
Re: 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 not equal. 3. When you get a match break out of the appropriate … | |
Re: 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. "manners" are the rules of good/polite behaviour. If you said "can someone please tell me … | |
Re: 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 semicolons, but the way you are defining the listener is the normal way to do … | |
Re: 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? | |
Re: I think well-formed just means it is correct in its syntax etc. | |
Re: 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 locked the object the second thread must wait until the lock is … | |
Re: 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. Back in the old days befor Java 1.5 the compiler would not convert automatically between Boolean (the class) members and boolean … | |
Re: [url]http://javabyexample.wisdomplug.com/java-concepts/34-core-java/70-invoking-win32-api-and-activex-components-com-dlls-from-java-ii.html[/url] | |
Re: 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 \\ | |
Re: [QUOTE=thines01;1038027]A default constructor is one that takes no parameters and sets the initial values for the class. [/QUOTE] 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 the … | |
Re: 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. | |
Re: [QUOTE=masijade;1037965]... I don't know how substring reacts if the end index is smaller than the start index..[/QUOTE] API doc states: [QUOTE]Throws: IndexOutOfBoundsException - if the beginIndex is negative, or endIndex is larger than the length of this String object, or beginIndex is larger than endIndex.[/QUOTE] | |
Re: If you put that code in your main class then the "this" on line 13 refers to an instance of the main class. When the same code is in class Panels, "this" refers to an instance of Panel. So maybe that's why the drawimage is doing something different? | |
Re: Where are the declarations of dob and telnumber (the instance variables, not the parameters)? | |
Re: All you are doing here is changing a String within your program. Where does this connect with the actual filesystem? | |
Re: It's annoying, but you can't use a primitive type (int/char/boolean etc) with generics. | |
Re: 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. | |
Re: str txtfNum1,txtfNum2,lblAnswer; did you mean String ? | |
Re: [QUOTE=javaAddict;1007036]What do you mean by that? Do you think it is wrong?[/QUOTE] No, there's nothing wrong with it all. It's definitely [I]not [/I]ambiguous! [CODE]addMouseListener(this);[/CODE] calls the addMouseListener method on the current object - the thing called "this". [CODE]this.addMouseListener(this);[/CODE] just makes that fact explicit, but the first "this" is unnecessary. People … | |
Re: 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? | |
Re: 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 public class CircularListIterator<F extends E> ... | |
Re: 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 properly. You need your method to match the name, scope, and return type EXACTLY to those defined in the Comparator, ie public int compare(BankCustomer customerOne, BankCustomer customerTwo); … | |
Re: 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. So it could be written [CODE] @Override public boolean equals(Person inPerson) { return name.equals( inPerson.getName() ) … | |
Re: 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. | |
Re: Move the declaration of au outside the action performed method, because now it exists only within that method. | |
Re: Don't be discouraged by ejosiah - looks like he's having a bad day! Does the problem happen on valid input data, or only on the test cases that have unmatched brackets? (Because it looks like you are popping one more item than you have pushed) | |
Re: package Assignment; Your compiled class file should be in a directory called Assignment, and the directory that contains the Assignment directory should be in the classpath. | |
Re: 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 defuakt character encoding. | |
Re: ... and put line 5 [B][I]outside [/I][/B]the loop! | |
Re: Because you have imported the packages, you can just call any of the public methods in those packages. Try it! | |
Re: Maybe not. The loop in lines 22/23 is a single statement loop. The calculation of the average on line 25 should be outside the loop, so the error is the superfluous } on line 18. | |
Re: Are you sure you want to close you input stream every time you read a line from it? | |
Re: Since your class extends (is-a-kind-of) LinkedList, you can just use the sort in Collections directly on your object: Collections.sort(this); (Although I suspect your prof may expect you to insert each object into the list in the right place, thus keeping it sorted all the time - loop thru the list … | |
Re: Have you tried setHeaderValue("..."); on your new TableColumn? |
The End.