Read the error: "Cannot convert from boolean to int", = Boolean.parseBoolean(values[3]);
What is wrong there?
|
Read the error: "Cannot convert from boolean to int", = Boolean.parseBoolean(values[3]);
What is wrong there?
casting - Convert boolean to int in Java - Stack Overflow
He wont understand it, just let him read and learn to google up on java.
They need to learn, you can't exactly spoonfeed everyone, this is why the community is wrecked. No one wants to learn, they want it all been given to them.
There are many resources out there for people to learn, thats why they are there...
I may not be the best programmer but atleast i try..
You are trying to write a boolean where a int is required.
Change
intoCode:p.skillLock[Boolean.parseBoolean(values[0])]
Code:p.skillLock[Integer.parseInt(values[0])]
I don't expect a spoonfeed, I expect an explanation that will actually help me understand the concept. I didn't know I was suppose to be converting a boolean to an int, I thought it was suppose to be just a boolean throughout the whole loading process. I tried googling it and didn't come up with much that applied to my scenario. Especially because I don't understand what parseint or parseboolean is and why I am setting one equal to the other. The language I am actually learning in college is C++, and I am only in my second class for it. So most of the things I run into in rsps (java) I have never even seen before.
Thanks it worked, but does that make it so the code sets the true or false boolean into an integer for the server to be able to read when loading the game?
It didn't seem like anything was wrong with the second part. Am I doing it wrong?
What you're getting is a String value (value[0]). Parsing in this case is turning a String object into a primitive type (int, long, boolean, ect). So you're reading in the array index which should be an int and using that to assign the correct boolean value to that index in the array.
In this case the array index is the skill's ID and the boolean assigned to that index tells the server whether the skill is locked or not.Code:p.skillLock[Integer.parseInt(values[0])] = Boolean.parseBoolean(values[3])
« Previous Thread | Next Thread » |
Thread Information |
Users Browsing this ThreadThere are currently 1 users browsing this thread. (0 members and 1 guests) |