- Strength to Increase Rep
- +8
- Strength to Decrease Rep
- -2
- Upvotes Received
- 145
- Posts with Upvotes
- 120
- Upvoting Members
- 62
- Downvotes Received
- 9
- Posts with Downvotes
- 8
- Downvoting Members
- 6
Re: 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 … | |
Re: 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 … | |
Re: 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 … | |
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 … | |
Re: `System.out.print((k>=10)?+k:" "+k)` is just a complicated way of writing `System.out.printf("%2d",k)`. | |
Re: > 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 … | |
Re: 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 … | |
Re: 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 … | |
Re: 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 … | |
Re: 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 … | |
Re: 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 … | |
Re: 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 … | |
Re: > 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 … | |
Re: > 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. … | |
Re: > 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 … | |
Re: `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 … | |
Re: 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 … | |
Re: 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 … | |
Re: 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 | |
Re: 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 … | |
Re: 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 … | |
Re: 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 … | |
Re: 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. … | |
Re: 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 … | |
Re: This looks like it should be helpful: http://mathforum.org/library/drmath/view/55783.html | |
Re: 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 … | |
Re: 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 … | |
Re: 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 … | |
Re: 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 … | |
Re: 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 … |