| | |
Method problems
Please support our Java advertiser: Programming Forums - DaniWeb Sister Site
![]() |
•
•
Join Date: Apr 2006
Posts: 114
Reputation:
Solved Threads: 0
For some reason this method prints out an extra integer at the bottom. For example: It is supposed to only print out 4 x4.
20 20 20 20
20 20 20 20
20 20 20 20
20 20 20 20
20
Any idea how to remove the extra character?
Any assistance will be great thanks, Kimjack.
20 20 20 20
20 20 20 20
20 20 20 20
20 20 20 20
20
Any idea how to remove the extra character?
public void gridOfChars(int gridSize) {
for (int i = 0; i < 2; i++) {
for (char n = 'A'; n <= 'Z'; n++)
{
gameList.add(n);
}
}
shuffle(gameList);
copyGameList = gameList.subList(0, (gridSize * 2));
temp = new ArrayList<Character>(copyGameList);
temp2 = new ArrayList<Character>(temp);
temp.addAll(temp2);
shuffle(temp);
gameList = temp;
//displays grid of chars for text display
int newLine = 0;
for (int a = 0; a <= (gridSize * gridSize); a++) {
newLine++;
System.out.print(" " + gameList.get(a));
if (newLine == gridSize)
{
System.out.println();
newLine = 0;
}
}
}Any assistance will be great thanks, Kimjack.
•
•
Join Date: Nov 2008
Posts: 332
Reputation:
Solved Threads: 53
0
#2 Oct 9th, 2009
Java Syntax (Toggle Plain Text)
for (int a = 0; a <= (gridSize * gridSize); a++) { for (int a = 0; a < (gridSize * gridSize); a++) {
![]() |
Similar Threads
- Laptop Monitor Turns Off When Windows Is Started (USB Devices and other Peripherals)
- Method problem (Java)
- Main Method: any suggestions? (Java)
- Method problems (Java)
- PHP vs ASP... the big ShOwdOwN (IT Professionals' Lounge)
- Sorting arrays of pointers with function? (C)
Other Threads in the Java Forum
- Previous Thread: Inheritance and Polymorphism
- Next Thread: Please Help! Can someone tell me what this error means and how to fix it?
| Thread Tools | Search this Thread |
-xlint add android api applet application array arrays automation bi binary blackberry bluetooth chat class classes client code compile compiler component converter database digit eclipse equation error event exception fractal freeze functiontesting game gameprogramming givemetehcodez graphics gui health html hyper ide idea image input int integer j2me java javame javaprojects jetbrains jni jpanel jtable julia learningresources linux list login loop main map method methods mobile myregfun netbeans newbie nonstatic notdisplaying page pearl print problem program programming project qt recursion scanner screen scrollbar server set size sms sort spamblocker sql string superclass swing system thread threads time tree variablebinding windows xor





