File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Beginning Java and the fly likes 2d Boolean Array Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of EJB 3 in Action this week in the EJB and other Java EE Technologies forum!
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "2d Boolean Array" Watch "2d Boolean Array" New topic
Author

2d Boolean Array

DANIEL GRESHAM
Greenhorn

Joined: Feb 09, 2005
Posts: 21
Fisrt of all forgive my ignorance, I'm only 5 weeks in on the language.
Im working on a 2d Boolean array that is represented as an imaginary floor, when moving my "rat" across the floor(also the name of the array), I need to be able to leave a trail if it is toggled by the user. almost all of the coding is done but I do not know how to return a Boolean value into a "floor space" as I travel across it can someone just give me a general idea of how to place a boolean value of true onto a 2d array that is already default as false? please do not give me the complete answer, just a gental kick in the right direction.
thanx
Jeroen Wenting
Ranch Hand

Joined: Oct 12, 2000
Posts: 5093
array[x][y] = true; usually does the trick.


42
Jeff Bosch
Ranch Hand

Joined: Jul 30, 2003
Posts: 804
Hi, Daniel -

If I understand what you're looking for, a simple assignment should do the trick. Because you capitalize Boolean, I'm assuming you are using Boolean objects, not primitive data types. You can't modify a Boolean object because the fields are final and there are no setter methods anyway. If you have an array of rows and objects, then you could create a new Boolean with the desired value and assign it to the array element you need to change.

Hope that helps...


Give a man a fish, he'll eat for one day. Teach a man to fish, he'll drink all your beer.
Cheers, Jeff (SCJP 1.4, SCJD in progress, if you can call that progress...)
Layne Lund
Ranch Hand

Joined: Dec 06, 2001
Posts: 3061
It would probably be easier to use the boolean primitive rather than the Boolean wrapper class. In such a case, an assignment will do the job of toggling the value.

Layne


Java API Documentation
The Java Tutorial
Jeff Bosch
Ranch Hand

Joined: Jul 30, 2003
Posts: 804
Very true, but if the professor wanted an array of Boolean objects and the student uses an array of boolean primitives, guess what the grade will be!
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: 2d Boolean Array
 
Similar Threads
"2D array"
Arraay doubt
boolean array
Resultset from Action class to JSP ?
How to convert Char array to two dimensional string