+ 11

Int to String [Java]

Hey. for some reason i thought that this code would work can anyone explain whats wrong with it please. int i = 1000; System.out.println(""+i.charAt(1)); Thanks

12th Mar 2018, 4:40 PM
D_Stark
D_Stark - avatar
4 odpowiedzi
+ 22
David, write : System.out.println ((""+i).charAt(1)) ;
12th Mar 2018, 4:47 PM
LukArToDo
LukArToDo - avatar
+ 21
😁 I know that you know. That's piece of cake for you... 😉 But for beginners this is an interesting question 👍
12th Mar 2018, 4:55 PM
LukArToDo
LukArToDo - avatar
+ 7
@luka lol i knew that 😏 thank you 😉
12th Mar 2018, 4:50 PM
D_Stark
D_Stark - avatar
+ 4
wow, I've been wondering why so much emphasis is placed on order of operations & this question (& the solutions) brought the point home. I usually just put my expressions in variables to avoid trouble, but i realize now that it's easy to do these kinds of computation without. Thanks guys :)
14th Mar 2018, 10:07 PM
G.T.T
G.T.T - avatar