Any help is appreciated. Thanks.
Aha! I had a char variable and I didn't set it to 0. I didn't know you had to set everything to 0, especially letters...and it said it wasn't initialized. It's fixed now, thanks.
You can set it to anything.
As for the char... a char is actually a number, so setting it to 0 is alright. If it was a string, you'd want something like ... String x = "";
But it can be anything -- The problem is when anything looks at that variable before anything is put IN the variable...you get errors. Sometimes you might be looking at that variable without even realizing it, which just causes infinitely more confusion. So always remember to initialize it to SOMETHING.
package CardGame.Gameplay; import CardGame.Helpers.*; import CardGame.Cards.*;
// Player's 'Hand' ... Just a list of cards. public class Hand { private List cards = new Empty();
public Hand() { }
public void addCard(Card toAdd) { this.cards.add(toAdd); }
public void removeCard(Card toRemove) { this.cards.removeCard(toRemove); }
}
p.s.: ALWAYS initialize your variables... Don't write int x; Write int x = 0;
Otherwise you're opening the door for null pointer exceptions which are stressful and hard to track down.
(Edited by Plastik at 4:05 pm on Sep. 23, 2005)
You'll also need them for blocks such as: When there is more than 1 line to do after an "IF" statement
When there is more than 1 line to do after a "WHILE" statement
etc.
...if there's still a problem, send me the code in question and I can almost definetly show you exactly where the problem(s) are.
(Edited by Plastik at 3:53 pm on Sep. 23, 2005)
(Edited by knotsotypikal at 4:18 pm on Sep. 23, 2005)