7,116 Posted Topics

Member Avatar for girl.java

Here's another clue. It should have been a boolean. And calling it "n" was an act of crass stupidity.

Member Avatar for JamesCherrill
0
108
Member Avatar for algo_man

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 …

Member Avatar for JamesCherrill
0
112
Member Avatar for touch me not

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).

Member Avatar for JamesCherrill
0
74
Member Avatar for Izzywizz

[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]

Member Avatar for cale.macdonald
0
873
Member Avatar for HazardTW

Why are you using getName? The internal name isn't usually a user-meaningful thing. Try using getText().

Member Avatar for HazardTW
0
139
Member Avatar for TotalHack

[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]

Member Avatar for JamesCherrill
0
160
Member Avatar for topest1

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?

Member Avatar for topest1
0
604
Member Avatar for bonzi200x

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, …

Member Avatar for JamesCherrill
1
113
Member Avatar for Nagarajan.M

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.

Member Avatar for majestic0110
0
80
Member Avatar for Nightryno

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 …

Member Avatar for JamesCherrill
0
231
Member Avatar for wrenz.go
Member Avatar for Xiek

the letter cannot be both Q and q, so one or the other conditions must be true, so their OR is always true.

Member Avatar for Xiek
0
83
Member Avatar for rukshilag

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.

Member Avatar for kudresov
0
244
Member Avatar for Camzie

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, …

Member Avatar for JamesCherrill
0
152
Member Avatar for kenji

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???

Member Avatar for JamesCherrill
0
98
Member Avatar for kumaran21

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: …

Member Avatar for JamesCherrill
0
157
Member Avatar for d0pe

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 …

Member Avatar for d0pe
1
104
Member Avatar for MxDev

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 …

Member Avatar for MxDev
-3
166
Member Avatar for geek_till_itMHZ

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 …

Member Avatar for geek_till_itMHZ
0
183
Member Avatar for Ballen92

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?

Member Avatar for Ballen92
0
787
Member Avatar for kiranpvsr
Member Avatar for Devoted Hosting
0
145
Member Avatar for eleal

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 …

Member Avatar for Devoted Hosting
0
161
Member Avatar for sridhar123

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 …

Member Avatar for Ezzaral
0
238
Member Avatar for futureaussiecto

[url]http://javabyexample.wisdomplug.com/java-concepts/34-core-java/70-invoking-win32-api-and-activex-components-com-dlls-from-java-ii.html[/url]

Member Avatar for JamesCherrill
0
84
Member Avatar for jrosh

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 \\

Member Avatar for JamesCherrill
0
123
Member Avatar for brokenbentou

[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 …

Member Avatar for JamesCherrill
0
167
Member Avatar for nonshatter

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.

Member Avatar for Cronless
0
212
Member Avatar for skiplatte

[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]

Member Avatar for masijade
0
96
Member Avatar for CuteCat

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?

Member Avatar for CuteCat
0
192
Member Avatar for whiteyoh

Where are the declarations of dob and telnumber (the instance variables, not the parameters)?

Member Avatar for whiteyoh
0
105
Member Avatar for anki.gulsvart

All you are doing here is changing a String within your program. Where does this connect with the actual filesystem?

Member Avatar for JamesCherrill
0
77
Member Avatar for chunalt787
Member Avatar for chunalt787
0
4K
Member Avatar for gonzila

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.

Member Avatar for gonzila
0
105
Member Avatar for xonxon
Member Avatar for kathmartir

[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 …

Member Avatar for FriQenstein
0
5K
Member Avatar for shakunni

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?

Member Avatar for eggmatters
0
108
Member Avatar for Fire00f1y

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> ...

Member Avatar for ~s.o.s~
0
172
Member Avatar for nateuni

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); …

Member Avatar for nateuni
0
96
Member Avatar for Samyx

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() ) …

Member Avatar for Jocamps
0
146
Member Avatar for bruceaj

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.

Member Avatar for quuba
0
317
Member Avatar for tonief

Move the declaration of au outside the action performed method, because now it exists only within that method.

Member Avatar for tonief
0
86
Member Avatar for nicolek808

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)

Member Avatar for ejosiah
0
2K
Member Avatar for bentlogic

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.

Member Avatar for peter_budo
0
347
Member Avatar for fareast87

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.

Member Avatar for fareast87
0
105
Member Avatar for JRabbit2307
Member Avatar for babylonlion

Because you have imported the packages, you can just call any of the public methods in those packages. Try it!

Member Avatar for babylonlion
0
112
Member Avatar for JRabbit2307

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.

Member Avatar for masijade
0
1K
Member Avatar for Flanderbland

Are you sure you want to close you input stream every time you read a line from it?

Member Avatar for Flanderbland
0
196
Member Avatar for Tussles

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 …

Member Avatar for ejosiah
0
138
Member Avatar for Clawsy

The End.