Skip to Main Content

Java APIs

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

string as boolean in array

843810Apr 10 2004 — edited Apr 14 2004
Hey, im new to all this,
in the class name i have made a
boolean [ ] thing and in the contructor i have said, thing = new boolean[5];
ln a particular method called getProperty i have prompted the user with a question, if they type "y" i want 'true' to be stored in the array and if "n" then 'false' otherwise an error message is printed
I have tried for ages to get this to work using a String named temp
i have gone

public void getProperty()
String temp;

for(int i = 0, i<5, i++)
temp = keyboard.readString("question?")
if temp = 'y'
{
thing[ i ] = true;

but i get
incompatible types
found: java.lang.string
required: boolean
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on May 12 2004
Added on Apr 10 2004
5 comments
167 views