So I was wondering how can I parse variables or letters instead of it just being integers...
Examples would be nice, please.Code:int z = Integer.parseInt
|
So I was wondering how can I parse variables or letters instead of it just being integers...
Examples would be nice, please.Code:int z = Integer.parseInt
to parse a string just set the variable to the token. to parse a character just set the variable to the x element of the string where x = the character's position in the string. i don't think there's any static methods you can use to parse whole strings or individual characters
e.g. in PI's player saving system, the token variable is called 'token2', to set the player's email you'd do something like this
or if you want only the first characterCode:} else if (line.startsWith("Email")) { p.Email = token2;
Code:} else if (line.startsWith("Email1stchar")) { p.Email = token2.toCharArray()[0];
you'll have to surround in try/catch NumberFormatException, but you should be using an IDE so that'll come naturallyCode:String s = "34"; int i = Integer.parseInt(s);
« Previous Thread | Next Thread » |
Thread Information |
Users Browsing this ThreadThere are currently 1 users browsing this thread. (0 members and 1 guests) |