| | |
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: 54
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?
Views: 169 | Replies: 1
| Thread Tools | Search this Thread |
Tag cloud for Java
911 addressbook android api append apple applet application arguments array arrays automation binary bluetooth character chat class classes client code component csv database detection draw eclipse error event exception file fractal ftp game givemetehcodez graphics gui helpwithhomework html ide image input integer j2me japplet java javaarraylist javaprojects jmf jni jpanel julia linux list loop map method methods mobile netbeans newbie number object objects oracle oriented os panel print problem program programming project projects recursion replaydirector reporting researchinmotion return robot rotatetext scanner screen se server set size sms socket sort sql stream string swing test threads time transfer tree ubuntu windows





