Posts
 
Reputation
Joined
Last Seen
Ranked #209
Strength to Increase Rep
+8
Strength to Decrease Rep
-2
94% Quality Score
Upvotes Received
145
Posts with Upvotes
120
Upvoting Members
62
Downvotes Received
9
Posts with Downvotes
8
Downvoting Members
6
28 Commented Posts
9 Endorsements
Ranked #207
Ranked #236

226 Posted Topics

Member Avatar for tensity

It probably doesn't matter, but storing the suit as a string seems pointlessly wasteful. I might not go so far as to store the rank of the card in a `short` in the name of efficiency, but I would definitely store the suit as an `enum`. Your `getSuit` can convert …

Member Avatar for Hunter_2
0
2K
Member Avatar for Pobunjenik

You should never ever go into an infinite loop in the event dispatch thread. That would cause your whole application to freeze. Look at this if you aren't sure how to use javax.swing.Timer: http://docs.oracle.com/javase/7/docs/api/javax/swing/Timer.html I think you want `new Timer(500, listener)`. I put 500 instead of 100 because you said …

Member Avatar for sishenyelang
0
1K
Member Avatar for dwel

I have watched about 0.1% of this series, but it seems like it could be good: [Derek Banas Java Video Tutorial](http://www.youtube.com/playlist?list=PLE7E8B7F4856C9B19) There is also this site where they expect you to buy a subscription, but what I have seen of their videos hasn't shown me where the money goes. You …

Member Avatar for Rajeev Kumar_1
0
472
Member Avatar for bguild

I've noticed that there are various icons around the site that aren't appearing for me in Firefox the way they appear in Internet Explorer. They seem to be characters without the font needed to render them. I have attached a screenshot that shows the effect, most obviously next to the …

Member Avatar for Dani
1
876
Member Avatar for darylglenng

`System.out.print((k>=10)?+k:" "+k)` is just a complicated way of writing `System.out.printf("%2d",k)`.

Member Avatar for pallav89
0
643
Member Avatar for matthewwhite011

> Some day in the future man will evolve without brains due to lack of use. It's not just a joke. It might actually happen. We evolved our brains thanks to the survival of the fittest in prehistoric times when we needed a large amount of cleverness just to get …

Member Avatar for Reverend Jim
0
962
Member Avatar for happygeek

Nothing on the internet should ever be trusted totally. Just as operating systems should be designed with the assumption that each piece of software may be the enemy, games should be designed with the assumption that each player may be the enemy. The most important element of ensuring players have …

Member Avatar for mrgreen
1
514
Member Avatar for kevinyu

I did some experimenting because I am a little rusty at Android java, but I managed to get something like what you want working. I think your big mistake is accessing the Internet from the UI thread. I'm surprised that doesn't cause an exception for you because my Android emulator …

Member Avatar for kevinyu
0
235
Member Avatar for bumsfeld

There are some interesting design choices in Nimrod. I read the tutorial and it not only explained how to use the language; it also sometimes mentioned reasons for some of the features and many of those reasons are about efficiency. The compiler requires forward declarations because looking ahead would slow …

Member Avatar for rubberman
1
332
Member Avatar for gagun

I'm certainly not an expert, but it looks like you are calling `findViewById` before it is ready. You should probably avoid calling it until after you have called `setContentView` in `onCreate`. From the documentation for `findViewById`: "Finds a view that was identified by the id attribute from the XML that …

Member Avatar for cool_zephyr
0
878
Member Avatar for jemz

Drawing is normally done in the `paint` method using the `Graphics` that you are given. You cannot create a `Graphics` using `new Graphics()` because that is forbidden. It is possible to draw outside of the `paint` method, but those are advanced techniques that you probably don't need because they are …

Member Avatar for jemz
0
1K
Member Avatar for Pobunjenik

Just looking at the code I believe I see several problems. On line 48 I suspect you are demonstrating one of the major problems with copy-and-paste code. I think you really want that line to say `if(locationJ.toArray()[j] == positionJ)`. You should prefer using a private method instead of copying your …

Member Avatar for JamesCherrill
0
2K
Member Avatar for godzab

> When I try to remove a number, it removes the whole right side. That is what you should expect when you do `temp.setNext(null)` because nulling the link of `temp` makes `temp` the end of the list. If you want to remove just one element then you need to get …

Member Avatar for godzab
0
237
Member Avatar for asif49

> I have been told that when entering the US, customs officials can insist that you reveal the password for an engrypted file or partition. And if you refuse... > you'd just be detained even longer and probably end up with a terrorism charge just to get you to cooperate. …

Member Avatar for jwenting
0
751
Member Avatar for bibiki

> the instance of the builder is passed to Builder.build(this) method That sounds like you are passing an instance of `Builder` to a static method of `Builder`, which seems very unlikely. I can think of two answers to your question. My favorite is that objects that never change are easier …

Member Avatar for bibiki
1
161
Member Avatar for CoilFyzx

`javax.swing.JTable` is a class with many features and complexities, but I am sure that it can't do what you are asking for directly. I recommend that you use ordinary `javax.swing.JLabel`s for your top column headings and then use two `JTable`s, one for "Subjects" and one for "Group Letters". That won't …

Member Avatar for JamesCherrill
0
946
Member Avatar for Violet_82

You normally don't have access to the instance variables of an object. If you want encapsulation, you need to make your fields `private`, and that means you can't call `printf` with the instance variables from anywhere outside of the class. On the other hand, it is good practice to make …

Member Avatar for Violet_82
1
227
Member Avatar for ceelos1974

The answers to your questions seem to reach all the way down to the fundamentals of Java programming. If you would show us your failed attempts to make these things happen we could probably easily explain why your attempts were failing, but otherwise the only answers that I can think …

Member Avatar for ceelos1974
0
229
Member Avatar for peymankop

It sounds like you want `javax.swing.JFileChooser`. You can learn all about how to use it in this tutorial: http://docs.oracle.com/javase/tutorial/uiswing/components/filechooser.html And in the javadox: http://docs.oracle.com/javase/6/docs/api/javax/swing/JFileChooser.html

Member Avatar for bguild
0
130
Member Avatar for overwraith

There is a big difference between a field and a local variable. You must not treat them lightly. When you say `JButton team1` on line 28 you are creating a local variable called `team1` and every time you use the name `team1` in the method after that you are using …

Member Avatar for overwraith
0
177
Member Avatar for maxcatozzi

You are ignoring whatever error messages you might be getting. There are many kinds of `java.io.IOException`, and each one will at least include a stack trace that will tell you exactly which line of your source code is causing the exception. The `IOException`s may even include a helpful error message …

Member Avatar for stultuske
0
1K
Member Avatar for parkz16

A field and a local variable that happen to have the same name are otherwise completely unconnected. Only the name is the same. It is much like having a method and a local variable with the same name. As far as the compiler is concerned, it is just a trivial …

Member Avatar for bguild
0
33K
Member Avatar for riahc3

while ( user.length() == 0 ){ System.out.println("Please insert a valid member"); } > This is the correct way to do validation in a production application. I don't know why it got voted down, but as a user of a production application I would find that sort of validation highly unpleasant. …

Member Avatar for peter_budo
4
878
Member Avatar for DarkLightning7

On line 31 you are creating a new array for the reference `n`. On line 32, you are testing if `n` is contained in `closedSet`. Since the `n` array never existed before that moment, there is no way it could be in `closedSet`. That will surely prevent your algorithm from …

Member Avatar for DarkLightning7
0
275
Member Avatar for Varunkrishna
Member Avatar for bguild
0
228
Member Avatar for Violet_82

The details are available here: http://docs.oracle.com/javase/7/docs/api/java/util/Formatter.html Format specifiers look like this: `%[argument_index$][flags][width][.precision]conversion` The number `6` is in the `[width]` position, which means that 6 is the minimum number of characters in the result. If the argument string has 6 characters or more, the argument string will be output as it …

Member Avatar for Violet_82
0
237
Member Avatar for somjit{}

The `add` documentation for `AbstractCollection` is actually rather shameful. When a class is designed to be extended the documentation should go far beyond merely explaining what each method does. A few preconditions and postconditions are fine documentation for a `final` method, but someone who is overriding a method also needs …

Member Avatar for somjit{}
0
176
Member Avatar for ankit.pandey3

This is something you can easily do yourself! Just take your numeral one digit at a time from left to right and keep an accumulator that starts at 0. For each digit, multiply the accumulator by the base and then add the value of the digit. You can reverse the …

Member Avatar for bguild
0
294
Member Avatar for Stuugie

The `exec` method does not necessarily use your command the same way that your command prompt uses it. Practically everything that `exec` does is operating system dependent, so it's hard to make any promises about how it should be used, but you shouldn't assume that it is as sophisticated as …

Member Avatar for Stuugie
0
687
Member Avatar for greyfox32

For those who don't know, a [`java.util.ConcurrentModificationException`](http://docs.oracle.com/javase/7/docs/api/java/util/ConcurrentModificationException.html) is thrown by some iterators when they detect that the collection has been modified. Very few iterators can tolerate modifications happening to the thing they are trying to iterate over in the middle of iteration, so you don't allow one thread to modify …

Member Avatar for bguild
0
262
Member Avatar for game06

You have forgotten to include the details of the error. Remember that error messages are not mere annoyances; they are someone's sincere attempt to help you, so you should read them, take them seriously, and share them with anyone else who wants to help you. So if your error includes …

Member Avatar for bguild
0
144
Member Avatar for codys21

It is usually very simple to track down the cause of a `NullPointerException` compared to most exceptions. It just means that some reference was null when an object was required, so all you need to do is go to the line in your source code that most directly caused the …

Member Avatar for bguild
0
500
Member Avatar for Violet_82

Actually, there is no problem with having only one `return` statement in the `if` part and one in the `else` part. The compiler is surely smart enough to recognize that one `return` or the other is inevitable. The problem comes from the fact that it is possible for `myarray` to …

Member Avatar for Violet_82
0
172
Member Avatar for jared.j.roberts.7

The `public static void main(String[] args)` method is where you put what you want your class to do when it is run. Your `main` method does nothing as there is nothing in the `{}`, so you are literally telling your class to do nothing.

Member Avatar for radhakrishna.p
0
187
Member Avatar for joseph.lyons.754

You should check the documentation for the `JdbcRowSetImpl` constructor that you are calling. It is never safe to call any method or constructor without reading the documentation, so it is general good advice to always check the documentation. In this case a quick search found documentation for a `com.sun.rowset.JdbcRowSetImpl` that …

Member Avatar for JamesCherrill
0
379
Member Avatar for newGains

I'm not sure that I understand your requirements correctly, because surely a solution as simple as this is too easy: if(scores[i]<0 || scores[i]>100) throw new IllegalArgumentException("Invalid score found: s[" + i + "] = " + scores[i]); Even so, that seems to do what you are asking for.

Member Avatar for JamesCherrill
0
303
Member Avatar for tingwong

I can't find any problems with it, except that it is bad style to use static fields where local variables could be used, such as `queue` and `huffTree`. The `compress` method is also strangely named since the output file is much larger than the input file, so it's far from …

Member Avatar for Schol-R-LEA
0
1K
Member Avatar for Forte1292

I suspect you may be making a mistake about 40320. It looks like you have to account for every permutation of 9 digits, which means 362880 permutations, not 40320, and of course it is hopeless to try to number every state distinctly with 40320 numbers if there are 362880 states. …

Member Avatar for bguild
0
152
Member Avatar for modesto916

You don't need to do anything to your frame class to fill a frame. All frame classes (including `java.awt.Frame` and `javax.swing.JFrame`) come with `add` methods that can be used to fill a frame with stuff, so that means that frame classes are ready to be filled without any modifications.

Member Avatar for stultuske
0
209
Member Avatar for eod731

An `ArrayList` is even easier to use than an array for a project like this, so you should expect that your project will be made simpler if you do it correctly. The first step is to read [the documentation for `ArrayList`](http://docs.oracle.com/javase/7/docs/api/java/util/ArrayList.html). It is difficult and error-prone to attempt to use …

Member Avatar for bguild
0
241
Member Avatar for jspence29

It is madness to use `JOptionPane` to collect input from the user in the `paint` method. The `paint` method is called whenever the applet needs to paint itself, which could happen at almost any time so it is practically unpredictable. For example, if the dialog box covers any part of …

Member Avatar for bguild
0
315
Member Avatar for game06

You could have each `asteroid` keep track of whether it is touching the player, and only count it as a hit when the player touches an asteroid that it previously was not touching. That would let the player move through an asteroid, but if you want to prevent that you …

Member Avatar for bguild
0
187
Member Avatar for G_S

Even so, the teacher is also correct when he says that a field is simply a variable. After all, in most practical ways a field is like a local variable that happens to have a longer life and larger scope. Perhaps the teacher is trying to make a clear distinction …

Member Avatar for G_S
0
196
Member Avatar for fatalaccidents

Your `findAllEndings` method is puzzling. Your `isFound` variable is never used. Your `tries` variable is used only on line 16 where its value is always 0, meaning that you are ignoring all but the first element of `endswith`. You increment `tries` on line 19 even though it is never used …

Member Avatar for bguild
0
180
Member Avatar for michael.yeh.18062

I haven't tried these tools, but their websites all look promising, so you may want to look at them: [GOLD Parsing System](http://goldparser.org) [Grammatica](http://grammatica.percederberg.net) [ANTLR (Another Tool for Language Recognition)](http://www.antlr.org)

Member Avatar for Assembly Guy
0
307
Member Avatar for Lynick

Your requirements are not entirely clear, but it sounds like you want to create a method like private Set<Float> promptForFloats() throws NumberFormatException And then you can simply do something like this: Set<Float> result; try { result = promptForFloats(); } catch(NumberFormatException e) { result = promptForFloats(); } findAndPrintSum(result);

Member Avatar for Lynick
0
356
Member Avatar for nova4005

The `Play` method goes against Java naming conventions that almost everyone follows. See: [Code Conventions for Java](http://www.oracle.com/technetwork/java/codeconv-138413.html) The `startPosition` field is being used like a local variable, not a field. Your `else if` on line 328 is never going to happen. Returning an `ArrayList<Song>` from `getSongList` means that it would …

Member Avatar for nova4005
1
468
Member Avatar for overwraith

The performance of `StringBuilder` is sufficient for most common purposes. Arrays work quite well when you are mostly appending small strings to the end of a string, and that is a very natural way for strings to be constructed in most applications. If you want to deal with long strings …

Member Avatar for overwraith
0
261
Member Avatar for modesto916

You don't need to do any thinking in order to find a division algorithm. You can just borrow a division algorithm that is in common usage, such as [long division](http://en.wikipedia.org/wiki/Long_division).

Member Avatar for bguild
0
1K
Member Avatar for Pobunjenik

> how do I covert a String "0101" to an int 5? The conventional way is `Integer.parseInt("0101", 2)`. If you want to learn how to do it yourself, then just go from left-to-right with a accumulator that starts at 0. For each digit you multiply the accumulator by 2 and …

Member Avatar for Pobunjenik
0
366

The End.