Posted: Wed Nov 30, 2005 2:21 pm Post subject: How do you convert Strings to chars?
Hey, is there any class I can import from the API That would allow me to conver Strings to a character like if the string was 'a' to conver that to a character... or String 'Apple' would be character 'A'
The reason why, I want to have JOptionPane ask for a certian output, than I want to make an if statement
If(they wanted this than)
Do all this
if(they entered thise than)
do this
else
do this certian action.. something like system.out.println("NOOB");
Ok thanks guys...
Sponsor Sponsor
wtd
Posted: Wed Nov 30, 2005 2:29 pm Post subject: (No subject)
Java:
myString.charAt(0)
xLockx
Posted: Wed Nov 30, 2005 6:49 pm Post subject: (No subject)
Hmm sorry could you be more specific for example
here is a peice of my code
Posted: Wed Nov 30, 2005 11:37 pm Post subject: (No subject)
I dont like this in Java, Everything starts at 0. Even an array of [4] means it is really of 5. 0,1,2,3,4. This concept confuses me a lot since I just switched from turing to Java. Same with character locations. They start at 0 too. Any comments/opinion?
Sponsor Sponsor
wtd
Posted: Wed Nov 30, 2005 11:42 pm Post subject: (No subject)
MysticVegeta wrote:
I dont like this in Java, Everything starts at 0. Even an array of [4] means it is really of 5. 0,1,2,3,4. This concept confuses me a lot since I just switched from turing to Java. Same with character locations. They start at 0 too. Any comments/opinion?
It's a very very common convention, so get used to it.
When you declare an array with "[4]", you are allocating space for 4 items, not 5.
This becomes more clear if you understand how arrays work in C. Think of the subscript as meaning: "this element is located at the beginning of the array plus some number of spaces."
MysticVegeta
Posted: Thu Dec 01, 2005 9:09 am Post subject: (No subject)
wtd wrote:
MysticVegeta wrote:
I dont like this in Java, Everything starts at 0. Even an array of [4] means it is really of 5. 0,1,2,3,4. This concept confuses me a lot since I just switched from turing to Java. Same with character locations. They start at 0 too. Any comments/opinion?
It's a very very common convention, so get used to it.
When you declare an array with "[4]", you are allocating space for 4 items, not 5.
This becomes more clear if you understand how arrays work in C. Think of the subscript as meaning: "this element is located at the beginning of the array plus some number of spaces."
yeah i have to get used to it, cant make the java people change the language for me now can i? lol
Illidan Stormrage
Posted: Thu Dec 01, 2005 2:40 pm Post subject: (No subject)
Don't help this guy, he's too much of a n00b. I know how to do it, he just needs to apply his Java skills. This is how he's been getting by this whole course, by other people.
MysticVegeta
Posted: Thu Dec 01, 2005 2:43 pm Post subject: (No subject)
Illidan Stormrage wrote:
Don't help this guy, he's too much of a n00b. I know how to do it, he just needs to apply his Java skills. This is how he's been getting by this whole course, by other people.
I smell flame/anger. By the ways, Not everyone is good at compsci, programming is just one of the things you get by practising and interest, if the person doesn't have an interest, its not his fault is it? Besides, if you are better than him in compsci, he might be better than you in something else like art, math, science, etc.. Also, the word "n00b" is offending for beginners. Have a little respect for new people.
JackTruong
Posted: Thu Dec 01, 2005 4:19 pm Post subject: (No subject)
MysticVegeta wrote:
I dont like this in Java, Everything starts at 0. Even an array of [4] means it is really of 5. 0,1,2,3,4. This concept confuses me a lot since I just switched from turing to Java. Same with character locations. They start at 0 too. Any comments/opinion?
Starting at 0 is just one of those things you have to accept. I mean, why does November have 30 days? Can you change it? What about the year, 2005 is it? It can easily be the year 7574 or 44.
It was agreed upon by many people that the year is 2005, so everybody is in agreeance. Same with Java, arrays start at 0 because it was agreed upon.
If you don't like Java's method, then forget it, Java isn't for you. Switch to VB if you want to start at 1 or whatever number you choose.
Dan
Posted: Thu Dec 01, 2005 4:26 pm Post subject: (No subject)
Illidan Stormrage wrote:
Don't help this guy, he's too much of a n00b. I know how to do it, he just needs to apply his Java skills. This is how he's been getting by this whole course, by other people.
Pleases refrain from insuating peoleop on this site, epsltaly in the help sections. People on this site are not going to do peoleops home work for them but we do offer help on questions about progaming and progaming conspects. I see nothing wrong with his questions and i think that you need to repsected his right to learn. Also since you only have 1 post on this site i do not think you should be calling any one a "n00b".
Computer Science CanadaHelp with programming in C, C++, Java, PHP, Ruby, Turing, VB and more!
Illidan Stormrage
Posted: Thu Dec 01, 2005 5:23 pm Post subject: (No subject)
Hacker Dan wrote:
Illidan Stormrage wrote:
Don't help this guy, he's too much of a n00b. I know how to do it, he just needs to apply his Java skills. This is how he's been getting by this whole course, by other people.
Please refrain from insulting people on this site, especially in the help sections. People on this site are not going to do people's home work for them but we do offer help on questions about progaming and progaming conspects. I see nothing wrong with his questions and I think that you need to repsected his right to learn. Also since you only have one post on this site I do not think you should be calling anyone a "n00b".
I know this guy personally, and we call each other n00b all the time, it's no big deal. But he does always get other people to basically do his work for him. Today he actually addmitted he is a n00b. Oh, and post count has nothing to do with being a n00b. You could be a "veteran" and still be a n00b. I have encountered several "veterans" who are n00bs. Still, what he wants to do is highly easy, and I can show it to him tomorrow how to do it. And I fixed your spelling mistakes.